Need to add another data type...help!

snorf3

Registered User.
Local time
Today, 20:43
Joined
May 25, 2001
Messages
45
I've been trying to use this code to get my forms to autofill based on the previous record. My data types include boolean, integer, and text. How do I modify the following code to reflect this? I'm just a very early beginner with coding!

This is what I have now but it is not working:

Dim FillFields As String, FillAllFields As Integer
 
Dim FillFields As String
dim FillAllFields As Integer
 
Thanks for the suggestion. Unfortunately, it doesn't seem to make any difference. I'm still getting a "type mismatch" error message.

Any other thoughts?
 
Here's what I have right now. It came from the MS help article Q210236. The form I am trying to use this on is also embedded as a subform within another form. Does that make any difference?

-------------------------------
Option Compare Database

Option Explicit

Function AutoFillNewRecord(F As Form)

Dim RS As DAO.Recordset, C As Control
Dim FillFields As String
Dim FillAllFields As Integer

On Error Resume Next

'Exit if not on the new record.
If Not F.NewRecord Then Exit Function

'Goto the last record of the form recordset (to autofill form).
Set RS = F.RecordsetClone
RS.MoveLast

'Exit if you cannot move to the last record (no records).
If Err <> 0 Then Exit Function

'Fet the list of fields to autofill
FillFields = ";" & F![AutoFillNewRecordFields] & ";"

'If there is no criteria field, then set flag indicating ALL fields should be autofilled.
FillAllFields = Err <> 0

F.Painting = False

'Visit each field on the form.
For Each C In F
'fill the field if ALL fields are to be filled OR if the
'...ControlSource field can be found in the FillFields list.
If FillAllFields Or InStr(FillFields, ";" & (C.Name) & ";") > 0 Then
C = RS(C.ControlSource)
End If
Next

F.Painting = True

End Function
 
It looks like FillAllFields should be a boolean value. Try this..

dim FillAllFields As boolean
 
D-Fresh: Thanks but I tried it and it still doesn't work.

Do you think the problem is strictly with the data types? Or does having this function on a subform maybe cause some problem with recognition of stuff?
 

Users who are viewing this thread

Back
Top Bottom