Argument not optional

dawson321

Registered User.
Local time
Today, 06:50
Joined
Jun 6, 2010
Messages
29
Hi,

I am writing some code for a database button but the error message argument not optional appears, saying that my OpenForm is incorrect. The code is below can any body help? Thanks.

Private Sub Command47_Click()
DoCmd.OpenForm.[tbljobs main]
DoCmd.GoToRecord , , acNewRec
DoCmd.ApplyFilter "jobs form search, , ,"
End Sub
 
You need to use

DoCmd.OpenForm "tbljobs main"
 
Also, if you are going to a new record you should not be trying to apply a filter as well.
 
Hi,

Having a problem with this code again. It worked but the filter in the code has stopped working and I can't figure out why, can you help? thanks.

DoCmd.OpenForm "tbljobs main"
DoCmd.GoToRecord , , acNewRec
DoCmd.ApplyFilter "jobs form search, , ,"
 
As boblarson has already said, if you are opening to a new record then you should not be trying to apply a filter as well.

You need to drop either the
Code:
DoCmd.GoToRecord , , acNewRec
or the
Code:
DoCmd.ApplyFilter "jobs form search, , ,"

Both are performing different filters which is why you aren't getting the results you expect - though I'm not sure what you're expecting the results to be anyway...
 
Yea but if i just do the filter then other peoples information is visible in the back ground which is not suitable for confidentiality reasons.
 
Then drop the

Code:
DoCmd.GoToRecord , , acNewRec

EDIT - what happens if you perform the filter first and then go to a new record? i.e.

Code:
DoCmd.OpenForm "tbljobs main"
DoCmd.ApplyFilter "jobs form search, , ,"
DoCmd.GoToRecord , , acNewRec
 
Yea but if i drop that bit of code then other clients information is visible in the background, while the user enters the search criteria.
 
Yea but if i drop that bit of code then other clients information is visible in the background.
Okay, first things first.

1. If you want to add a record to the filtered set, that is fine.

2. However, you need to apply the filter (and I would not use DoCmd.ApplyFilter, I would use the Me.Filter and Me.FilterOn code instead) and THEN go to a new record. You don't go to a new record and then apply the filter.
 
Can you zip up your db and upload it here, minus any sensitive data?
 
Not letin me save it as a zip

How are you doing it?

You would

1. Run Compact and Repair from the database.

2. Close the database

3. Right click on the file and select SEND TO > COMPRESSED FOLDER

That will zip it up.
 

Users who are viewing this thread

Back
Top Bottom