|
-
Mar 31st, 2005, 05:11 AM
#1
Thread Starter
Addicted Member
Access SQL help
Hey all,
I have a Access form with a Variable that stores a Building Number
What i would like to do is list all the rooms that are in that building using the variable can anyone help?
i think the SQL would go somthing like this!
VB Code:
SELECT tbl_Room.Room_No, tbl_Room.Building_No
FROM tbl_Room;
WHERE tbl_Room.Building_No = Variable1
can anyone please solve this
Thanks
-
Mar 31st, 2005, 05:15 AM
#2
Addicted Member
Re: Access SQL help
try this:
VB Code:
"SELECT tbl_Room.Room_No, tbl_Room.Building_No" _
& " FROM tbl_Room " _
& " WHERE tbl_Room.Building_No = " & Variable1 & ";"
formatted the way i would use it within VBA
if you fail to plan, you plan to fail
-
Mar 31st, 2005, 05:23 AM
#3
Thread Starter
Addicted Member
Re: Access SQL help
Thanks for the reply
I'm using the SQL editor for the Row Source property of a Combo box
I placed the SQL in the SQL editor, run the Program and when i click on the dropdown box i get this error message
'Datatype mismatch in criteria expression'
any idea?
-
Mar 31st, 2005, 05:39 AM
#4
Addicted Member
Re: Access SQL help
ah ok,
the previous statement is what you would use in a module.
to do this in the combo box source i would reference the form as you said the variable was on the form?
e.g.:
VB Code:
SELECT tbl_Room.Room_No, tbl_Room.Building_No
FROM tbl_Room;
WHERE tbl_Room.Building_No = [Forms]![YourForm]![YourTextBox]
if you fail to plan, you plan to fail
-
Mar 31st, 2005, 06:16 AM
#5
Thread Starter
Addicted Member
Re: Access SQL help <<RESOLVED>>
Thanks worked great
cheers
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|