AutoFillNewRecord...Refusing to allow data change in one field

Rich_Lovina

Registered User.
Local time
Tomorrow, 10:40
Joined
Feb 27, 2002
Messages
224
I have successfully installed Module forAutoFillNewRecordFields. It can be set to carry forward all data from previous record.

However, one strange problem: The only field in the form (from a Many-side table) tied by RI to another table, cannot be changed on the next new record WITHOUT clicking back to the previous record and saving it first.

I have looked at all Properties and find no reason where this field differs.

Is there something additional to the following code required?

Option Explicit
Function AutoFillNewRecord(F As Form)
Dim RS As DAO.Recordset, C As Control
Dim FillFields As String, 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
' Get 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

Tks, there must be a simple solution.
 
When you finish filling out your form and before you move to the next one do a: DoCmd.RunCommand acCmdSaveRecord to be sure that the current record has been saved.
 
Now I GUESS this line will go just above the END IF line? Or is it just above END FUNCTION?
 
Thanks greatly, Jack. I chose to put extra code after NEXT and its working well. Helping me dump in fast another 6,000 names.

I hate to be pedantic about this VB, but there remains an ability for the user to just 'Keep Clicking forward' (onFwrd Arrow bar)and hence keep pasting the same record many times over.

What (learning) suggestion would you have to "Paste prevrecord data once only"?

Also would I start with DLookup function(again
frown.gif
!), if I want to say:
If a past record (same dbase!Form)based on 3 matching fields matches the just entered record, create Msgbox saying "You are creating a duplicate based on Inits, Surname and Deptname...Skip this record Yes/No". The sub-routine would start on exiting Deptcode field; and if yes, return cursor to Field with TabIndex1.

Tks in advance for clues....
smile.gif


[This message has been edited by Rich_Lovina (edited 01-10-2002).]
 

Users who are viewing this thread

Back
Top Bottom