As I am a novice, you are going to need to give me some
simpler instructions. I want it to open to a new form
with new primary key every time the switch board button
is clicked. Can you give me an easy to understand step by
step way forward.
I think I am using the built in switch board created by
Accesses switchboard manager - but it was a while back so
can't remember. However, I have of course created my own
buttons to press.
If this is a command button on the switchboard that you have added, in
Design View right-click on the command button. Display the property
sheet. Click on the Events tab.
On the line that says On Click it will say [Event Procedure].
Click on that line A button with 3 dots will appear. Click on that
button.
The Click event code window will appear with already existing code.
One of the lines will say something like:
DoCmd.OpenForm "FormNameHere"
It may, or may not, have additional code on that line.
If there is more code on that line, count the commas. At the end of
this line add enough commas so that in total there are 6 of them. Then
Add "GoToNew" (with the quotes).
The entire line should look like this.
DoCmd.OpenForm "FormName", , , , , ,"GoToNew"
Again, a total of 6 commas.
Exit the code window.
Open the Form that you wish to open at a new record.
Display the Form property sheet.
Click on the Event line.
Find the Load event. Type [Event Procedure] on that line.
click on the button with the 3 dots that will appear.
The code window will open with 2 lines of existing code.
BETWEEN those lines write:
If Me.OpenArgs = "GoToNew" then
DoCmd.RunCommand acCmdRecordsGoToNew
End If
Exit the code window. Save the Form.
The above can not be used with the Microsoft Switchboard made using
the Switchboard manager. But it can be used with any additional
command buttons you place on that switchboard.
You can tell if the Switchboard was made by the switchboard manager by
checking the Tables. If there is a "Switchboard Items" table, it was
made by the manager. The above will not work. But if you add a command
button to the switchboard, using the Tool Box, the above will work in
that command button click event.