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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open form in Datasheet view 5

Status
Not open for further replies.

lppa

Technical User
Apr 5, 2004
26
0
0
US
I need to open form in Datasheet view, so I set properties default view to Datasheet. It works ok from Database window, but when I open form from Switchboard it opens in Form view.
Any suggestions.
Thanks.
 
This is because the Switchboard does not open forms in Datasheet view. However, with a couple of minor modifications to the table Switchboard Items and to the form Switchboard you can accomplish this.

Open the table Switchboard Items in Design View. Add a Text field named Argument2 and save the new table settings.

Open the form Switchboard in Design View. In the Code Module, change the code from:
Code:
            DoCmd.OpenForm rst![Argument], , , , acAdd

...to:
Code:
            DoCmd.OpenForm rst![Argument], IIf(Nz,rst![Argument2], "") = "acFormDS", 3, 0), , , acAdd

...and save the new form settings.


Open the table Switchboard Items and look for the switchboard item you wish to modify. You should see an entry something like this:

[tt]
SwitchboardID | ItemNumber | ItemText | Command | Argument | Argument2
------------------------------------------------------------------------------
1 | 0 | Main SwitchBoard | 0 | Default |
1 | 1 | Open My Form | 2 | MyForm |
[/tt]

In the field Argument2, for the record you wish to edit (in the above example, the record with ItemText Open My Form), enter acFormDS and save the record:
[tt]
SwitchboardID | ItemNumber | ItemText | Command | Argument | Argument2
------------------------------------------------------------------------------
1 | 0 | Main SwitchBoard | 0 | Default |
1 | 1 | Open My Form | 2 | MyForm | acFormDS
[/tt]

Now, when you open the form from the Switchboard, it should show open the form in Datasheet View.
 
Thanks very much for your prompt respond, but it gives me a Syntax error message.
 
Whoops. Make that change in the code from:
Code:
        ' Open a form in Add mode.
        Case conCmdOpenFormAdd
            DoCmd.OpenForm rst![Argument], , , , acAdd

        ' Open a form.
        Case conCmdOpenFormBrowse
            DoCmd.OpenForm rst![Argument]

...to:
Code:
        ' Open a form in Add mode.
        Case conCmdOpenFormAdd
            DoCmd.OpenForm rst![Argument], IIf(Nz(rst![Argument2], "") = "acFormDS", 3, 0), , , acAdd

        ' Open a form.
        Case conCmdOpenFormBrowse
            DoCmd.OpenForm rst![Argument], IIf(Nz(rst![Argument2], "") = "acFormDS", 3, 0)
 
Still not working. My original code is:

' Open a form in Add mode.
Case conCmdOpenFormAdd
DoCmd.OpenForm rs![Argument], , , , acAdd

' Open a form.
Case conCmdOpenFormBrowse
DoCmd.OpenForm rs![Argument]

If I change rs! to rst! It gives me error executing command
 
Now I got it. Everything is working fine.
Thanks.
 
Hi Ippa,

I cannot get this to work either. I was wondering if you could post the code that fixed your error.

Best regards,

Henry
 
Hi Henry,
Thanks for following up. This is the code I'm using and everything is working:

' Open a form.
Case conCmdOpenFormBrowse
DoCmd.OpenForm rs![Argument], IIf(Nz(rs![Argument2], "") = "acFormDS", 3, 0)
 
Ippa,

Thanks for the code. I'll try it tomorrow. Up til now I have used a subform in an unbound form as a workaround. Works but it's sloppy in my opinion.
 
Ippa,

Got it to work. Your help is much appreciated. I give you and Byte a STAR.

Best regards,

Henry
 
Hi Henry,
Thanks. I’m glad it worked out.
 
I followed the instructions here but I am experiencing the same problem described by Ippa originally. Any thoughts on what to look at? I am currently using Microsoft Access 2000.

 
des,

You must be missing something, it works fine for me in 2000. Are you sure you followed instructions exactly. Where did you put the following code (from Ippa):

' Open a form.
Case conCmdOpenFormBrowse
DoCmd.OpenForm rs![Argument], IIf(Nz(rs![Argument2], "") = "acFormDS", 3, 0)
 
This is what I have in the code. I commented out the original DoCmd.

' Open a form.
Case conCmdOpenFormBrowse
' DoCmd.OpenForm rs![Argument]
DoCmd.OpenForm rs![Argument], IIf(Nz(rs![Argument2], "") = "acFormDS", 3, 0)

I created a second Switchboard item, my "Voice Integration Form Menu". However, I don't see where that could create a problem. Each form linked to the switchboard is set to Open in Edit mode instead of ADD modem. Is that a problem?
 
Sorry, I must ask again, where EXACTLY (sorry for shouting) did you put that code?

Did you build the switchboard yourself or did you use the wizard. I have built many "switchboards" but they are far different from those built by the wizard. My handmade switchboards are just an unbound form with buttons that open other forms, print reports, etc. They are not controlled, by code, according to items stored in a table as a wizard built form.
 
I used the Switchboard Manager in MS Access to do all of the work on this switchboard.
 
If you have built your own switchboard using a Form try the code below on a Button to open your form

DoCmd.OpenForm "YourFormName", acFormDS

Hope this helps
Hymn
 
I got it work by deleting the old switchboard and using the main form.
 
Have you altered the code in the function?:

"Private Function HandleButtonClick(intBtn As Integer)"

If you have done these things and altered the table as shown, I have no other ideas :(

 
Hymn,

Thanks for that, personally I don't like the Switchboard manager.

Des,

Glad you got things sorted out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top