?
Solved

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

Posted on 2012-08-30
7
Medium Priority
?
548 Views
Last Modified: 2012-08-30
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
Comment
Question by:SeyerIT
  • 4
  • 3
7 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 38349769
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
 
LVL 61

Expert Comment

by:mbizup
ID: 38349774
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
 
LVL 2

Author Comment

by:SeyerIT
ID: 38349776
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

by:SeyerIT
ID: 38349780
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
 
LVL 61

Expert Comment

by:mbizup
ID: 38349784
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
 
LVL 61

Expert Comment

by:mbizup
ID: 38349787
Oh okay - glad you've got it fixed.
0
 
LVL 2

Author Comment

by:SeyerIT
ID: 38349788
Thanks for your input as well mbizup.. Simple mistake.. I figured that was going to be the case.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question