Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2003
    Posts
    42

    Unanswered: Nearly finished a DB - Need a little help...

    Hi,

    I was wondering whether someone could help me. I’ve been working extremely hard on a relational database for a small car hire company. Anyway, I’ve nearly finished the database now but I have a problem. On a form I have created called ‘Customer’, I have a text box entitled, ‘txtDrivingLicenceNumber’. This takes data from a field called ‘DrivingLicenceNumber’ from a table called ‘Customer’. What I need is, when you click a button called ‘Add Rental’ (the button should be called cmdAddRental), a new record should be created in a form entitled, ‘Rents’, BUT the driving licence number should ALSO be carried over into the new record in the Rents form and displayed on the screen in a text box. Does anyone know how to do this?

    Secondly, I have created a text box called, ‘txtSettled’ on the Rents form. This Y or N flag is my trap to re-find a customer by searching for rentals from a Main Menu form based on their driving licence number. Only if the driving licence number matches AND the settled flag is set to N would a record be returned, all the rest would be previous settled hires.

    Does anyone have any idea how to do either of these? ANY help would be very much appreciated.

  2. #2
    Join Date
    Dec 2003
    Location
    Budapest, HU
    Posts
    18
    1.

    I guess when you click on the 'Add Rental' button a form will appear where you wish to pass the DLN automatically from the 'Customer' form.

    To do this, use OpenArgs argument of OpenForm method:

    DoCmd.OpenForm "Rents", , , , , , txtDrivingLicenceNumber

    The OpenArgs property of the opening form takes the value you passed in the OpenArgs argument of the OpenForm method.

    When the 'Rents' form is opening, you can use the form's OpenArgs property to assign the value to the text box in 'Rents' form:

    txtDrivingLicenceNumber = OpenArgs

    2.

    If you wish to return the record(s) in a continuous form, use WhereCondition argument of the OpenForm method. The syntax of WhereCondition argument is just like a WHERE clause of an SQL statement, but without the WHERE keyword. You can use this:

    DoCmd.OpenForm "RentalList", , , "[DrivingLicenceNumber]='" & txtDrivingLicenceNumber & "' and Settled='N'"

    where txtDrivingLicenceNumber is the field or a local variable storing the DLN you're searching for.

    BRegs,

    TBÁrpi

  3. #3
    Join Date
    Dec 2003
    Posts
    42
    Hi,

    Thank you for kindly helping with this. I've just tried the first of your two points. In my Customer form I have the text box called, 'txtDrivingLicenceNumber' and in my Rents form I have the text box called, 'txtDrivingLicenceNumberRents'. I want the data from the Customer form (txtDrivingLicenceNumber) to be displayed in the Rents form (txtDrivingLicenceNumberRents) when the Add Rental button is clicked. I've made the button and added this code to the Customer form in the Form Open method...

    DoCmd.OpenForm "Rents", , , , , , txtDrivingLicenceNumber

    And this code to the Rents form in the Form Open method...

    txtDrivingLicenceNumberRents = OpenArgs

    However, when I click the Add Rental button, I get an error that reads...

    "You can't assign a value to this object" and it refers to the txtDrivingLicenceNumberRents = OpenArgs reference.

    Any ideas?

  4. #4
    Join Date
    Dec 2003
    Posts
    42
    No need to worry, I set the focus and it now works - thank you very much!

  5. #5
    Join Date
    Dec 2003
    Location
    Budapest, HU
    Posts
    18
    If you think check http://www.dbforums.com/t972369.html to find some explanation of using OpenArgs.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •