switchboards

  • Thread starter Thread starter Lawrence Ryz
  • Start date Start date
L

Lawrence Ryz

On a similar note to someone else's post on switchboards.
I have created a swichboard with buttons. One button
takes you to a form which I created and then allows you
to input data. How can I get the switchboard to
automatically take you to a new record in the form, as
currently, it takes you to the first primary key entry
and I have to hit the last ">|" button on the form to
take me to the end of the entries and then enter new data.

Thanks in advance for anyone who can help.

Lawrence
 
On a similar note to someone else's post on switchboards.
I have created a swichboard with buttons. One button
takes you to a form which I created and then allows you
to input data. How can I get the switchboard to
automatically take you to a new record in the form, as
currently, it takes you to the first primary key entry
and I have to hit the last ">|" button on the form to
take me to the end of the entries and then enter new data.

Thanks in advance for anyone who can help.

Lawrence

Lawrence,
It depends.

1) If you would like the second form to ALWAYS open to a new record
simply code that form's Load event:
DoCmd.RunCommand acCmdRecordsGoToNew

If you only want it to open to a new record sometimes, and not at
other times ....
2) Are you using an unbound form with command buttons you added
yourself?

Add, to the code behind the switchboard command button that opens the
second form, so that it looks similar to this:
DoCmd.OpenForm "FormName", , , , , , "GoToNew"

Code the second Form's Load Event:
If Me.OpenArgs = "GoToNew" then
DoCmd.RunCommand acCmdRecordsGoToNew
End If

The form, will open to a new record only when opened by the
switchboard.
If you open it directly, it will open at the first record as it
normally does.

3) Are you using the Built-In Switchboard created by the Access
Switchboard manager?
If so, post back. It can be done there also, but I would do it in a
separate post as there is a bit of work involved.
 
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.
 
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.
 
Back
Top