Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Aug 2002
    Location
    Des Moines, Iowa, USA
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using a form field as a query parameter (XP)

    I have been reading up and studying how queries work using a form field as a parameter. When attempting one of my own, I received runtime error -2147217904 (80040e10) Parameter Forms ! frmInvoiceMaster ! txtAccountNumber has no default value.

    The form field being used in the query is unbound and is populated by the user in the initial form. When the "See Invoices" button is clicked on this form, a second form is opened. During the load event of the second form, the query is attempting to run. Attached is the Load procedure of the called form, and the query it references. Any help is appreciated.
    Attached Files Attached Files

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Using a form field as a query parameter (XP)

    If you can drop this DB back to Access 2000, I may be able to help.
    Pat <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Using a form field as a query parameter (XP)

    It doesn't appear to me that your code is populating txtAccountNumber, so how is the value getting into it? If there's no value in it and no default value for the control, then that may be what's causing your problem.
    Charlotte

  4. #4
    Star Lounger
    Join Date
    Aug 2002
    Location
    Des Moines, Iowa, USA
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using a form field as a query parameter (XP)

    You are correct. I have not yet put in the logic to error if no account number is entered, and the See Invoices button is pressed. The problem still occurs after a valid account number has been entered, and the See Invoices button is pressed. My programming should have been more explicit. I will put this logic into place, and continue working on why the account number value is not recognized in the query. Good observation.

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Using a form field as a query parameter (XP)

    You could try using the Nz function to return a value with 0 as the default. You can test the return value of the Nz function to see if it's zero in order to determine whether a valid account number was returned. Of course, that assumes you'll never have an account number of zero....

    Actually, while I think of it, I've seen a few problems referencing controls on a form in both 2000 and XP queries. You may need to wrap your criteria reference in an Eval function or a conversion function to get a usable value. Take a look at the thread that starts with <!post=Post 192840,192840>Post 192840<!/post> for more information on that.
    Charlotte

  6. #6
    Star Lounger
    Join Date
    Aug 2002
    Location
    Des Moines, Iowa, USA
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using a form field as a query parameter (XP)

    After verifying that a value was being returned, I decided to recreate the frmInvoiceDetail from the Form Wizard, attaching the qryInvoiceDetail and doing nothing else. When I ran frmInvoiceMaster, entered an account number, and clicked on the See Invoices button, all the information I was looking for appeared on frmInvoiceDetail. <img src=/S/bananas.gif border=0 alt=bananas width=33 height=35>

    I think this was an instance where I was making the situation harder than I needed. For some reason, I thought that a parameter needed to be passed to the query, but the query was set up to find the account value from frmInvoiceMaster. I appreciate your help and apologize for going blonde on you. <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>

Posting Permissions

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