• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 562
  • Last Modified:

Need help tweaking Where syntax in Docmd.openform vba in Access

Can't seem to get my filter quite right for some reason.. I thought I was on the right track after I did some searching on the internet but I'm getting an application error right now;
error
Here is my syntax;

Private Sub cmdOpenProg_Click()

DoCmd.OpenForm "frmHurcoSetups", , , "[ProgNum] = " & Forms!frmSplash.cboProgramNum

End Sub


Thanks for the help!
0
Jarred Meyer
Asked:
Jarred Meyer
  • 4
  • 3
1 Solution
 
mbizupCommented:
A couple of things to check...

1.  Make sure that frmSplash is open at the time this code is run, and that all the field, form and control names are correct.

2.  If ProgNum is text, use this instead;

DoCmd.OpenForm "frmHurcoSetups", , , "[ProgNum] = '" & Forms!frmSplash.cboProgramNum & "'"

3.  If cboProgramNum has multiple columns in its rowsource, make sure you are referring to the correct column


4.  Make sure that ProgNum is present as a field in the recordsource of frmHurcoSetups
0
 
mbizupCommented:
Also try opening frmHurcoSetups directly from the Access window. To make sure that there is nothing in the form's properties, Open Event, etc that is preventing this form from opening.
0
 
Jarred MeyerProduction ManagerAuthor Commented:
Hmm... I definitely forgot the quotations on ProgNum as you mentioned in #2 but that didn't get it either for some reason.. I double checked all the field and form names and frmSplash is open. Also cboProgramNum only has one column.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
Jarred MeyerProduction ManagerAuthor Commented:
Yeh.. Just figured it out.. Something simple of course.. My combobox on splash was actually called cboProgram not cboProgramNum as I put in my code.. Blah!

Thanks for the help!
0
 
mbizupCommented:
Your syntax (with the quotes for text) looks good.

Try recreating your popup frmHurcoSetups, to rule out the possibility of form corruption - you should be able to do this fairly quickly by selecting all controls and copy/pasting, and doing the same with any code.
0
 
mbizupCommented:
Oh okay - glad you've got it fixed.
0
 
Jarred MeyerProduction ManagerAuthor Commented:
Thanks for your input as well mbizup.. Simple mistake.. I figured that was going to be the case.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now