Go to last record

truck074

New member
Local time
Today, 11:43
Joined
Jul 27, 2007
Messages
3
I'm having trouble remembering how to create a form that doesn't pull from any recordsets, but when a button is pushed it sends all the information to the tables. I can create forms that allow the user to create a new entry, but that gives them access to other fields that i don't want them to edit.

Or at least for the being, how to create an action that when a form is opened from a button event, it goes to the very last record that is blank and allows the user to add a record.
 
What you need to do is create one generic form, and on the OnLoad event use a logical argument to check the OpenArgs and from there determine which controls are visible, editable etc.

Each button will send a different OpenArgs to the form. For example your add new record button might have OpenArgs = "New" and so on.

HTH
 
little help

could you give an example of some openArgs or whaterver your talking about if the textbox had a name of "NameID"
 
Or at least for the being, how to create an action that when a form is opened from a button event, it goes to the very last record that is blank and allows the user to add a record.
If you want to use this option (using a bound form) you could use:

DoCmd.RunCommand acCmdRecordsGoToNew

or you could just open the form in Data Entry Mode
 
could you give an example of some openArgs or whaterver your talking about if the textbox had a name of "NameID"

In the on click event of your button put the following;
Code:
    Dim stDocName As String
    
    stDocName = "FRM_Name"

    DoCmd.OpenForm stDocName, , , , , , "New"   [COLOR="Green"]'The last part of this line is the OpenArgs and could be any descriptor you choose[/COLOR]


In the OnLoad event for your form "FRM_Name" put the following;
Code:
     If Me.OpenArgs = "New" Then
          DoCmd.GoToRecord acForm, "FRM_Name", acNewRec
          [COLOR="Green"]'Insert instructions as to how you want your form to behave if the Add New button has been clicked[/COLOR]
     ElseIf Me.OpenArgs = "Last" Then
          DoCmd.GoToRecord acForm, "FRM_Name", acLast
          [COLOR="Green"]'Insert instructions as to how you want your form to behave if the Goto last button has been clicked[/COLOR]
     Else
          [COLOR="Green"]'Insert your forms default behavior[/COLOR]
     End If
 

Users who are viewing this thread

Back
Top Bottom