Full Version: Making an existing form open on a new record
UtterAccess Discussion Forums > Microsoft® Office > Microsoft Excel
concrete_brunette
Is there a way to make an existing form open on a new record? I now that there's some checkbox when doing a switchboard but I can't find that.
Aquadevel
concrete,

Do you mean you want a existing form open up blank, so you can add a new record?

If so try:

Docmd.openform "YourFormNameHere", , acNewRec

sad.gif
concrete_brunette
Thanks, but it is already on the switchboard. How do I do it there?
Aquadevel
You mean add a new button to the switchboard,

or modify the code of an existing button to:

Docmd.openform "YourFormNameHere", , acNewRec ?

If modify, open the switchboard in design mode, double click the button & on the window that opens up
look at the 'on-click' event. Click on that line to open up the code window.
concrete_brunette
Actually, it is a buton on the main switchboard. Where do I find the code to do this? I've got a nested form, so the way thatI get to it is like this

main form
|
|
L_Menu->Form that I want to open to new record.

Where do I do that? I cannot seem to find the code in the VB section.
Aquadevel
1. Open the form in design mode
2. double-click on the button in question, and the properties window will open up.
3. in the EVENTS list, look at the 'On-Click' event. It will have 'Event Procedure' on it.
4. Click on that line & to the right of that you will see [...]
5. click on the little [...] button
6. You will see the code
concrete_brunette
Right now all I see is this

=HandleButtonClick(4)

how do I edit that. All i get is this equation box.
Aquadevel
Remove the:

"=HandleButtonClick(4)"

Click on the 'On-Click' event line and select 'Event Procedure'.
Then click on the [...] little button to the right of that.

Put the code:

Docmd.openform "YourFormNameHere", , acNewRec <<~~~ change the form name to what your real form name is

It appears you used the 'Switchboard Mangler' to create your switchboard. Its better, IMHO, to create the
switchboard like any other form. It gives you more control over what & how things work.

Edited by: Aquadevel on Mon Jul 23 10:12:29 EDT 2007.
concrete_brunette
Yes, I did use switchboard manager. Can I still use the process you describe?
Aquadevel
to correct the button?
Yes

to create additional buttons?
yes

I MUST Need more coffee, I JUST noticed you posted in the Excel Forum,
I hope same thing works.

I'm NOT an Excel guy

sad.gif

Edited by: Aquadevel on Mon Jul 23 10:55:50 EDT 2007.
concrete_brunette
Me too. I had a long weekend.
norie
Is this an Excel or Access question?

If it's Excel I'll tell you straight away that DoCmd just doesn't exist in Excel VBA.
Aquadevel
Norie,

Does Excel even have a 'switchboard mangler'?

sad.gif
norie
Eh, of course it doesn't but there seems to be some confusion in this thread.

It has after all been posted in the Excel forum.dazed.gif
Aquadevel
Hey,

I'm not confused, I know where I think I am!

sad.gif
tlclady
I am trying to open an existing form with a command button. I want the form to open up blank. I tried the code you suggested, but it's not working. It still opens up populated rather than blank. Any ideas?

Here's the code behind the command button:

Private Sub New_Inspection_Click()
On Error GoTo Err_New_Inspection_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Inspection"
DoCmd.OpenForm stDocName, , acNewRec


Exit_New_Inspection_Click:
Exit Sub

Err_New_Inspection_Click:
MsgBox Err.Description
Resume Exit_New_Inspection_Click

End Sub


What do you think is the problem???
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.