Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / May 2007

Tip: Looking for answers? Try searching our database.

Update a query based on user input in a form.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
wooofer - 03 May 2007 07:43 GMT
I am trying to export a .txt query file with user specified data. A parameter
doesn't work because I get the error message when exporting that "too few
parameter. Expected 1" message. From reading other posts, I made a form that
will act as input for the query instead of just the parameter. Can someone
help me write the OnClick event that will update query. The query name is
qryInvoiceExport. I need the user to input the invoice number so that the
details of that particular invoice are listed. Also does anyone know if I
will also need to set the value of the parameter in addition to using the
form as input? Any guidance is much appreciated.
Klatuu - 03 May 2007 15:01 GMT
The easiest way to do this is to have a control on the form to enter the
invoice number.  Lets call it txtInvoiceNumber (clever naming, what?).  And
let's call the form frmInvLookup.

Then in the query builder, put the reference to the form and control in the
Criteria row of the Invoice Number column:

Forms!frmInvLookup!txtInvoiceNumber

Now all you need in the Click event of the command button is whatever
command you need to run the export.  I would also suggest you check to see
that a value is in the control and that it actuall exists in the table before
you do the export and get nothing:

   Do While True
       If IsNull(Me.txtInvoiceNumber) Then
           If MsgBox("No Invoice Number Entered", vbRetryCancel) = vbCancel
Then
               DoCmd.Close acForm, Me.Name, acSaveNo
               Exit Do
           Else
               Me.txtInvoiceNumber.SetFocus
           End If
       ElseIf IsNull(DLookup("[INVOICE_NUMBER]", "tblInvoice", _
               "[INVOICE_NUMBER] = '" & Me.txtInvoiceNUmber & "'") Then
           If MsgBox("Invoice Number " & Me.txtInvoiceNumber & " Not
Found", _
                   vbRetryCancel) = vbCancel Then
               DoCmd.Close acForm, Me.Name, acSaveNo
               Exit Do
           Else
               Me.txtInvoiceNumber.SetFocus
           End If
       Else
           DoCmd.TransferText........
           Exit Do
       End If
Signature

Dave Hargis, Microsoft Access MVP

> I am trying to export a .txt query file with user specified data. A parameter
> doesn't work because I get the error message when exporting that "too few
[quoted text clipped - 5 lines]
> will also need to set the value of the parameter in addition to using the
> form as input? Any guidance is much appreciated.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.