Open Table Command

TigerGyrlAlly

New Member
Joined
Jun 11, 2003
Messages
18
I have a button on a form and I would like for a user to be able to press the button and close the form while opening a table. I am using the OpenTable method of the DoCmd object and including all arguments but it still doesn't seem to work...does anyone see what i'm missing?

The error message that I get is this: Compile Error: Expected: =

This is my code and the part in red is where i'm getting my error
Private Sub ActButton_Click()
On Error GoTo Err_ActButton_Click
DoCmd.Close
color=yellow]DoCmd.OpenTable(Activity, acViewNormal , acReadOnly)

Exit_ActButton_Click:
Exit Sub

Err_ActButton_Click:
MsgBox Err.Description
Resume Exit_ActButton_Click
End Sub
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
This got a bit scrambled so I'm assuming you meant...

Private Sub ActButton_Click()
On Error GoTo Err_ActButton_Click
DoCmd.Close
DoCmd.OpenTable(Activity, acViewNormal , acReadOnly)

Exit_ActButton_Click:
Exit Sub

Err_ActButton_Click:
MsgBox Err.Description
Resume Exit_ActButton_Click
End Sub

You usually need to open the table before closing your form, but you also need to be specific about the object that you are closing.

Try:

Private Sub ActButton_Click()
On Error GoTo Err_ActButton_Click
DoCmd.OpenTable(Activity, acViewNormal , acReadOnly)
DoCmd.Close acForm,"MyForm"


Exit_ActButton_Click:
Exit Sub

Err_ActButton_Click:
MsgBox Err.Description
Resume Exit_ActButton_Click
End Sub

Changes are in BOLD. You'll need to change MyForm to the name of the form that you want to close.

Denis
 
Upvote 0

Forum statistics

Threads
1,221,687
Messages
6,161,287
Members
451,695
Latest member
Doug Mize 1024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top