Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating Switchboard Buttons

Status
Not open for further replies.

Prince0DC68

Technical User
Aug 29, 2008
1
US
Hello Experts -

I am creating my first dB project and already I am a little stuck. I'm trying to create a command button on a switchboard form that does three things at the same time; open another form, open a new record and set a value in one of the fields. The wizard seems to allow you to create one event but I need all three, can you help?

Dave
 
What is your actual code in the Click event procedure of the button ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
To open a form, you can use the wizard, if you want. To open to a new record, set the Data Entry property of the form to Yes. To set a value, do you mean a default value? Again, you can use the property sheet. Do you want some other value set? Please be more specific.
 
How are ya Prince0DC68 . . .

Use the switchboard manager to create a button that opens the form. Then replace the code in the button with the following:
Code:
[blue]   Dim frm As Form
   
   DoCmd.OpenForm "[purple][b]FormName[/b][/purple]"
   DoEvents
   Set frm = Forms![[purple][b]FormName[/b][/purple]]
   
   If frm.Recordset.RecordCount <> 0 Then DoCmd.RunCommand acCmdRecordsGoToNew
   'Use one of the following depending on string or numeric
   
   [green]'Numeric[/green]
   frm![[purple][b]TextboxName[/b][/purple]] = [purple][b]NumericValue[/b][/purple]
   
   [green]'Text[/green]
   frm![[purple][b]TextboxName[/b][/purple]] = "[purple][b]YourText[/b][/purple]"
   
   Set frm = Nothing[/blue]
[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top