Is there a way perform CTRL+' with vba code in MsAccess 2000

mshelley1

Carbo
Local time
Yesterday, 23:09
Joined
Feb 12, 2006
Messages
45
[RESOLVED] Is there a way perform CTRL+' with vba code in MsAccess 2000

Is there a way perform CTRL+' with vba code in MsAccess 2000

Carbo

CTRL+' copies data from a field in the previous record to that field in the current record.

Resolution:
http://support.microsoft.com/?id=210236

If you receive a compile error related to DAO Recordset go to:

http://www.mvps.org/access/bugs/bugs0031.htm
 
Last edited:
The code you pointed to does *not* execute unless you call it! They suggested calling it from the Current event of your form so it becomes automatic but it sounds like you want to call it from a button. It will work either way.
 
RG

Could you provide me with guidance on the best way to call the module using a button.

Thanks
 
Just put Call AutoFillNewRecord(Me) in the code of your button.
 
RG

When I run the module I get a Compile error “User-defined type not defined” Here is a copy of my code. (Problem area in red)

(Thanks in Advance)

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
 
Excellent! Thanks for posting back and glad I could help.
 

Users who are viewing this thread

Back
Top Bottom