Pre-populate form fields

EHS

Registered User.
Local time
Today, 05:35
Joined
Jun 23, 2011
Messages
22
Hi There
I'm trying to pre-populate some fields on a form using the following code in the on activate event:
With Me.CreatedBy
.Enabled = True
.SetFocus
.Value = tmpClass
End With
With Me.Location
.SetFocus
.Value = tmpLocation
End With
With Me.ReportedBy
.SetFocus
.Value = tmpStaffID
End With
With Me.Site
.SetFocus
.Value = tmpSite
End With
Me.CreatedBy.Enabled = False

It doesn't work. I've tried putting the code in the on open event, but the fields still remain blank. I've confirmed the variables e.g. tmpLocation, have the correct values. Any Ideas?
Thanks
 
First of all you don't need to SetFocus if you're referring to the Value property. The only time you need to SetFocus is when you're referring to the Text property.
 
Private Sub cmdAutofill_Click()

Me.Last_Name = Me.Combo267.Column(1)
Me.First_Name = Me.Combo267.Column(2)
Me.Middle_Initial = Me.Combo267.Column(3)
Me.Dvr_State = Me.Combo267.Column(4)

Select Case MsgBox("Is this Information Correct?", vbYesNo Or vbExclamation Or vbDefaultButton1, "Verify Information")
Case vbNo
Exit Sub
Case vbYes
End Select
End Sub

This is how I do an autofill on a form reading from a combobox.
 
Thanks for your help. I found the problem - a stupid mistake on my part.
Happy new year!
 

Users who are viewing this thread

Back
Top Bottom