954,184 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

VBA Combo Box Problem

Hi Guys,
I just need a bit of help in VBA.
What I'm trying to do is to open report from a form. The reports are based on Query.
The form consists of a combo box and a command button. What I want to do is to select the condition of opening the report from combo box and open that report.

Following is the code I'm using

1) Dealer = Form!DEALER_COMBO.Value

2) DoCmd.OpenReport "SALES REPORT", acViewPreview, , "[OKCUNM] = 'BATALION MOTORS'"
3)Text9.SetFocus
Text9.Text = Me.DEALER_COMBO.Value
4)DoCmd.OpenReport "SALES REPORT", acViewPreview, , "[OKCUNM]" = Form!DEALER_COMBO.Value

The second and third lines of code are just tests. OKCUNM is a field on the report which is running on a query.
If I comment line 4 everything works fine with the set condition in line 2, but I want the condition to be fulfilled by combo box which I'm trying to do in line 4.
In line 4 the value from Form!DEALER_COMBO.Value is not getting stored in OKCUNM
Please Help

saurabh_kanwar
Newbie Poster
20 posts since Sep 2006
Reputation Points: 10
Solved Threads: 0
 

Someone helped me with the solution already guys.

The code was supposed to be
DoCmd.OpenReport "SALES REPORT", acViewPreview, ,"[OKCUNM]='" & Form!DEALER_COMBO.Value & "'"

Thanks for your time

saurabh_kanwar
Newbie Poster
20 posts since Sep 2006
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You