Re: Update a table using a form



On Wed, 30 Nov 2005 06:27:02 -0800, "WGordon"
<WGordon@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

>This may be a hopeless case. I have the form set up to modify a field in a
>table (not enter a new record). I use the Auto Number as a reference to find
>the record I want to modify (usually the last record). When the form opens it
>always starts at the first record (#1). If I enter data into the form it
>modifies record #1. What I need to do is modify the last existing record in
>the table. This form is accessed thru a Main Menu I have set up. When I enter
>the code you suggested in the Open field it causes a "Compile Error:
>Ambigious name detected" and refers to another form. I tried changing the
>code to "DoCmd.GoToRecord acLastRecord" but this didn't help.
>I know how difficult it is to trouble shoot something you can't get your
>hands on. Thanks for the help.

Not at all hopeless - just need to figure out what the real problem
is!

Open the Form in design view.
View its Properties.
On the Events tab find the Open event.
Click the ... icon by it.
Choose Code Builder. Access will open a VBA editor window with the Sub
and End Sub lines below. Edit it to:

Private Sub Form_Open(Cancel as Integer)
DoCmd.GoToRecord acLast
End Sub

Two questions:

- How can you be sure that the LAST record is the correct one to edit?
- How are you opening the form? Might it better be based on a Query
which returns only the desired record, so the problem of navigating
doesn't arise?

John W. Vinson[MVP]

.



Relevant Pages

  • RE: Tracking Log In and Log Out times of Users
    ... AuditLogger is a Sub, not a module. ... A Report module is the same, except it is specific to that report. ... A module cannot have a Sub or Function ... I have a start-up form that opens when the database opens. ...
    (microsoft.public.access.modulesdaovba)
  • Re: delete rows
    ... 'delete it in the close it will exist only for that workbook. ... Private Sub Workbook_Open ... but will be available to anyone who opens the ... Dim Rng As Range, Rng1 As Range ...
    (microsoft.public.excel.programming)
  • RE: My Problem - Help Please
    ... On Error GoTo errorHandler 'Set error capture ... 'ON THE CODE LINE DIRECTLY BELOW, THE NEW INSTANCE OF EXCEL IS OPENED ... 'THIS LINE OF CODE OPENS THE NEW INSTANCE OF EXCEL. ... End Sub ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Modifying a record field value while not blocking it to others
    ... as it is effective only when you go out of the related field you just ... And of course again the record you are trying to modify has not to be 'open' ... someone opens that ID=12 record everything in it is locked. ... so the developer has to create their own work-around. ...
    (comp.databases.filemaker)
  • Re: Modifying a record field value while not blocking it to others
    ... And of course again the record you are trying to modify has not to be 'open' ... someone opens that ID=12 record everything in it is locked. ... often add a script line which opens a random record if the file holds enough ... system where customers use Credits when renting items and get Credits ...
    (comp.databases.filemaker)

Quantcast