Static data on a data input form

  • Thread starter Thread starter APHILLEY
  • Start date Start date
A

APHILLEY

I have a data input form tied to a database that calculates an install
price based on certain criterea. I want to be able to display some
static data on the form based on data entered in box 1 So say a user
inputs customer XYZ I want the name and contact info to show but still
allow me to enter header data.. Is this possible?
 
First, I would suggest a combo box to look the customer up. I would use two
columns, one for the name and one (hidden) with the key value to the customer
table. In the After Update event of the combo box, estatblish the customer
table as a recordset, do a FindFirst using the key value of the selected row
in the comb box to position your table to the correct row. Now to put the
data on the form, create an unbound text box for each field from the customer
table you want to display. Als in the combo box After Update, put the values
from the fields into the text boxes.
 
Although this example does not have two columns in the combo box, the
technique is the same:

Private Sub cboActivity_AfterUpdate()
Dim rst As Recordset
'Find the Activity Selected
Set rst = Me.RecordsetClone
rst.FindFirst "[Activity] = '" & Me.cboActivity & "'"
If rst.NoMatch Then
If MsgBox("Add Activity Number " & Me.cboActivity & " To the
Attribute Table", _
vbYesNo + vbQuestion + vbDefaultButton2, "Activity Not
Found") = vbYes Then
DoCmd.GoToRecord acDataForm, Me.Name, acNewRec
Me.txtActivity = Me.cboActivity
Me.txtDescription.SetFocus
Else
Me.cboActivity = Null
End If
Else
Me.Bookmark = rst.Bookmark
Me.txtDescription.SetFocus
End If
rst.Close
Set rst = Nothing

End Sub
 
Back
Top