
Originally Posted by
Bill Casanova
Is any code running? No, not as far as I know.
Trying to RUN the code in design view brings up an empty window called Macros with no macro names for this db.
The database must be in a trusted location, or code must be explicitly enabled to run. Sorry, I do not understand what this means.
Can you post the db here? I will be happy to do so, but it is 2336kB and too large to be posted as an attachment, even after deleting most of the books in Tbl Book.
I notice that zip files can be larger, but do not know how to convert it.
Is there any other way to send it to you?
I'm trying to follow what you are doing.
I have a table Booksx and a table Rooms.
I have a query that links Booksx and Rooms and has a prompt for [Which Room]
This query limits the output to books only in the requested Room.
I have a Form with an Unbounded Combobox, which I have called combo1, and I have supplied a value list of room numbers. The form also has a Button called OK.
Code:
The OK button has the following code attached to it, but does not open the report:
Private Sub OK_Click()
DoCmd.OpenReport "Rpt Books in room?", , , "Room = '" & Me.OK & "'"
End Sub
When you click a button, you can run an On Click event, but the button per se has no value. So Me.ok does not have any meaningful data.
I think what you were trying to do
I want to select a room from the ComboBox and press the OK button to open the report displaying
only books in the selected room.
is select a value from the combobox and open a report
In my case I'm using RoomNumber, so this is the code of the On Click in my test
NOTE: The debug.print is to show what value was selected from combo1. It is a useful debugging approach.
I have also opened the report in preview mode for debugging purposes ( no sense in wasting paper)
Code:
Private Sub OK_Click()
Debug.Print "Room selected was " & Me.Combo1.Value
DoCmd.OpenReport "Rpt Books in room?", acViewPreview, , "RoomNumber = '" & Me.Combo1 & "'"
End Sub
I hope this is helpful. No one is saying that events and vba is trivial. It takes time and practice. Good luck with your project.
Also, the free videos at Datapig, as Alan has suggested, are excellent. And are great refreshers from time to time.