Results 1 to 5 of 5

Thread: Access SQL help

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2004
    Posts
    144

    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:
    1. SELECT tbl_Room.Room_No, tbl_Room.Building_No
    2. FROM tbl_Room;
    3. WHERE tbl_Room.Building_No = Variable1
    can anyone please solve this

    Thanks

  2. #2
    Addicted Member
    Join Date
    Jan 2002
    Location
    Glasgow, Scotland
    Posts
    202

    Re: Access SQL help

    try this:

    VB Code:
    1. "SELECT tbl_Room.Room_No, tbl_Room.Building_No" _
    2. & " FROM tbl_Room " _
    3. & " WHERE tbl_Room.Building_No = " & Variable1 & ";"

    formatted the way i would use it within VBA
    if you fail to plan, you plan to fail

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2004
    Posts
    144

    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?

  4. #4
    Addicted Member
    Join Date
    Jan 2002
    Location
    Glasgow, Scotland
    Posts
    202

    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:
    1. SELECT tbl_Room.Room_No, tbl_Room.Building_No
    2. FROM tbl_Room;
    3. WHERE tbl_Room.Building_No = [Forms]![YourForm]![YourTextBox]
    if you fail to plan, you plan to fail

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2004
    Posts
    144

    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
  •  



Click Here to Expand Forum to Full Width