compile error on docmd.open table

Skip Bisconer

Who Me?
Local time
Today, 11:46
Joined
Jan 22, 2008
Messages
285
I am trying to open a view of some linked Excel spreadsheets with an option box using the select case statement. When I try to use the below code for the case statement I get the error "Wrong number of arguments or invalid property assignment." on the the docmd.OpenForm code. This code works fine with the OpenForm method on another option box.

Questions are there different arguments for tables? Or can you view linked tables through code?

Code:
Private Sub cmdViewSpreadsheet_Click()
 
Dim stDocName As String
 
Select Case Frame10
Case 1
    stDocName = "CurrentChargesBisconer"
    Me.Visible = False
    DoCmd.OpenTable stDocName, acNormal, , , , acDialog
    DoCmd.Restore
    Me.Visible = True
[COLOR=seagreen]'Case 2 - 12 follow this statement[/COLOR]
End Sub
 
Could it be because you used OpenTable instead of OpenForm?
 
Howzit

The open table syntax is

Code:
DoCmd.OpenTable tablename, view, datamode

e.g.

Code:
DoCmd.OpenTable stDocName, acViewNormal,acEdit

As you can see there are differnt arguments for opening tables, than there are for forms.
 
I guess then if I want to use the acDialog to pause the start form I have to make a form out of all the options?
 
Howzit

Yes - not best practice to open tables directly - for data entry (I assume you want to open it to edit it??). Best done using forms.
 
Thanks for the advice. These are linked tables so no changes can be made anyway but it's best to follow good practices.
 

Users who are viewing this thread

Back
Top Bottom