Populating a Form with a table

G

Guest

Hi,

I am stumped and I need some HELP, PLEASE.
I have a form(InvoiceAdjustments) which is created from a
table(Adjustments)and a second table(Invoice). I want the user to be able
to search on the table(Invoice) for a pre-esxisting invoice and if found
populate some of the fields on the form with values found on the Invoice
table and the rest will be manually entered. Would someone please offer a
suggestions, please. I'm sorry I have no code to show I have coded and
stripped that nothing looks right anymore.
 
G

Guest

This is most commonly done using a combo box.
Create a combo box control that has a row source based on a query that
returns the invoice numbers in the table. If the invoice number is not the
primary key, the query should return both.

If you have two fields returned in the query, make the combo a 2 column
combo. The primary key field should be the bound field. If the primary key
field is not the invoice number, set the column widths so the invoice number
is visible but the other field is not. Do this by setting the column widths
property so that that column has a width of 0.

Now, use the After Update event of the combo to locate the invoice and make
it the current record:

Private Function cboInvoice_Click()
Dim rst As Recordset

Set rst = Me.RecordsetClone

With rst
.FindFirst "[Invoice_Number] = '" & Me.cboInvoice & "'"
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With

Set rst = Nothing

End Sub

The code above assumes [Invoice_Number] is the primary key field and it is a
text data type.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top