Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading value of Text or Combo box in VB to select different Reports

Status
Not open for further replies.

Locoman

Technical User
Sep 25, 2002
38
GB
I am a relative newbie to using the Visual Basic underlying Forms, etc. I am trying to select different reports with a Form which displays various Parts data. In VB I have worked out how to select different reports based on a the state of a data type field OK, however I want to add an unbound user selection box on the form (just shows numbers 1-5) to further sub-divide the report choices.

I seem to be unable to read any data in from the unbound "box": I have tried Text, List and Combo box types with no effect. What have I not understood here?
 
Hi.

In a Combo Box you need to select row type as "Value List", not "Query/Table"; then enter the list into the rowsource value.

Also, check that you are refering to the name of the combo/textbox with the "1-5" in it. Names like "Me.txtRptBreakdown1to5" seem reasonable.

So, in your code where the user presses the "Go/Run Report" button after selecting the report and "1-5", refer to the combo box with its full name.

If you had some code to show me, that would probably aide things a little.

Hope this is what you want.
Regards,
Mr Big Dont be small. be BIG
 
I am assuming all your code is on the form not the report and that you are using either the long version name of the form or the ME! with your textbox when referencing it, hence Me!Textbox.
A sample of what you have so far would help me help you, otherwise not sure.
try an if statement if all else fails.
if me.textbox = 1 then
docmd.openreport "Report Name"
else if me.textbox = 2
etc
end if

Put this on your after update even on the textbox itself.
 
Thanks for your suggestions folks, they gave me some useful reminders.
I have now solved my problem and you may be interested in the answer as it may be unusual?. It appears that the lack of function of the text or combo boxes is due to some sort of corruption to the Code entry screen for the Form, which I can only assume is due to the multiple edits whilst I was trying things out.

Although I had deleted all the junk that can get left behind with lots of edits, I knew something was wrong when I could not get any new boxes or option buttons to remember mouse clicks or keyboard strokes. Starting the form design again from scratch with a "clean sheet" solved the problem and it worked first time!




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top