Autofill new record based on previous record (1 Viewer)

snorf3

Registered User.
Local time
Today, 22:31
Joined
May 25, 2001
Messages
45
I'm trying to get my form to autofill some of its fields based on the record immediately previous to it.

I tried the module given in article Q136127 but I get this error message:

"The expression OnCurrent you entered as the event property setting produced the following error: Type mismatch."

I followed the instructions given in the article to the letter...I have the exact same code in my module.

My OnCurrent property reads:

= AutoFillNewRecord([Forms]![Clinical assessment])

Any ideas as to why this isn't working? I geatly appreciate any help you can offer!
 

raskew

AWF VIP
Local time
Today, 16:31
Joined
Jun 2, 2001
Messages
2,734
A fairly simple way is, in the AfterUpdate event of the control, set the default for that control as its current value. Here's an example of a text box containing a numeric entry. Note that the format will change slightly if referring to text or date (examples shown).

Private Sub FacilityID_AfterUpdate()
If Not IsNull(Me.FacilityID) Then
Me.FacilityID.DefaultValue = "=" & Me.FacilityID
'Use
'For text fields 'Me.Operatorid.DefaultValue = "='" & Me.OperatorID & "'"
'For date fields 'Me.Operatorid.DefaultValue = "=#" & Me.Operatorid & "#"
'For number fields 'Me.Operatorid.DefaultValue = "=" & Me.Operatorid

Me.FacilityID.TabStop = False
Else
Me.FacilityID.TabStop = True
End If

End Sub
 

Users who are viewing this thread

Top Bottom