Command Button Problems

mesci

Registered User.
Local time
Today, 08:35
Joined
Jul 24, 2002
Messages
27
Hi!

I've designed a subform for my main form, with a series of command buttons to open pop-up forms for data entry purposes.

The command buttons work fine when you purely open the subform as a form. However when I put the subform into the main form and try to work the command buttons from here the following message is displayed:

Syntax Error (missing operator) in query expression '[DatabaseID]='

DatabaseID is the field be which I'm matching the subform and popup form data.

Can anyone shed some light on this?
 
Try the following for your query expression

Forms!MainFormName!SubformName.Form!DatabaseID
 
Thanks for this John.Woody, I'm a bit of newbie at some aspects of Access, and have set this command up via the wizard.

If I go into the properties of the command button and then into the module info, should I put the info you provided in this section? or am I missing the plot completely? :confused:

Cheers!
 
If you go into the module behind one of the command buttons you may see a condition which refers to the formyou are trying to open. Or if your popup form is based on a query, the query may hold the parameter as a reference to the sub form directly. Wherever it is you need to change it to reference the sub form via the main form, hence the string in my previous post.

And hey I was a newbie once, and compared to some I still am.:D
 
Can't see the stars for the clouds!!

Hi John.Woody,

I still can't see the stars for the clouds - probably staring at this screen for too damn long..... :)

Am I grasping this theory right? that if my Main Form is originally called 'Main Form', my subform is called 'Grading' and the pop-up form is called 'CS Extension new due date'

and I have the following string (including your section):

Private Sub Command135_Click()
On Error GoTo Err_Command135_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "CS Extension new due date"

stLinkCriteria = "[Forms!Main Form!Grading.Form!DatabaseID]=" & Me![DatabaseID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command135_Click:
Exit Sub

Any ideas on where I'm losing the plot....?

All help is v.greatly appreciated....

:(
 
Private Sub Command135_Click()
On Error GoTo Err_Command135_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "CS Extension new due date"

stLinkCriteria = "Forms!CS Extension new due date!DatabaseID=Forms!Main Form!Grading.Form!DatabaseID"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command135_Click:
Exit Sub

I've confused myself now but I think

CS Extension new due date is the form you want to open
Main Form is your main form
Grading is your sub form

Both "CS Extension new due date" and Grading have a control called DatabaseID

By the way it is good practice not to have any spaces in the middle of form or control names ie
CS_Extension_new_due_date or
CSExtensionnewduedate is better than
CS Extension new due date etc
just a tip:)
 
Thankyou!

Cheers for this,

I'll give it a try out and let you know how I get on! and thankyou for the tip - I appreciate any advice!

Cheers once again!

:D
 

Users who are viewing this thread

Back
Top Bottom