Results 1 to 4 of 4
  1. #1
    Hank44 is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2010
    Posts
    2

    Need Help with SQL Statement

    I have 2 forms. Both have a field (MasterBillNo) I already have an on click event that navigates from the 1st form to the second. I need to search the <Airwaybills> table for all of the records that have the same (Masterbillno) and automatically populate some fields on the next form based on the 1st record returned in the recordset. The fields are (AirlineName),(Flightdate)



    The 1st form has the (Masterbillno) field to use in a search string. There will be several records that have the same (MasterbillNo)

    I need this to work with my navigational on_click event.

    Can anyone help?

  2. #2
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Hi Hank,

    You gave very little to go on. I've read this several times and I still don't have any idea on how to help - could you be a little more specific? (remember - we can't see your mdb)

    Where is the SQL? What is the table structure, how are they related, what code do you have? Maybe attach a copy of your mdb?

  3. #3
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,044
    Hi Hank,

    it's been a few years since I worked with airwaybills, so correct me if I'm wrong, but as I remember it the bill number is a text field. Then the sql string shoulb be build like:

    strSQL = "select * from Airwaybills where Masterbillno = """ & me.Masterbillno & """"

    if the bill nr. is a number field you don't have to include the strings so it should read as

    strSQL = "select * from Airwaybills where Masterbillno = " & me.Masterbillno

    greetings
    NG

  4. #4
    Join Date
    Aug 2010
    Posts
    2
    If I'm understanding your question correctly, the simplest way to do this is to create a query that the new form will be based on (to use as the Record Source of the second form.)

    In the query you can reference a field value on any other active form in Access. So in the QBE grid, in the criteria row (for the field that you want to search the airbill numbers) and use the value from the field on the first form as the criteria value. The syntax would be:

    =[Forms]![FormName]![FieldName]


    -J


Please reply to this thread with any new information or opinions.

Similar Threads

  1. SQL like statement?
    By Cojack in forum Queries
    Replies: 4
    Last Post: 09-21-2010, 04:45 AM
  2. Help with Iif statement
    By tmcrouse in forum Queries
    Replies: 2
    Last Post: 09-02-2010, 09:00 AM
  3. If Then Statement Help
    By Kapelluschsa in forum Programming
    Replies: 5
    Last Post: 08-11-2010, 09:24 AM
  4. IIf Statement
    By dref in forum Forms
    Replies: 2
    Last Post: 07-16-2010, 02:46 AM
  5. IIf Statement...HELP!
    By bdhFS in forum Queries
    Replies: 5
    Last Post: 05-19-2010, 07:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums