Form opened on new record - cant pre populate field

CallMeAndy

Registered User.
Local time
Today, 09:10
Joined
Jun 21, 2005
Messages
14
Private Sub City_NotInList(NewData As String, Response As Integer)
DoCmd.OpenForm "City", , , , acFormAdd, acDialog, NewData
Response = acDataErrAdded
End Sub

Private Sub Form_Open(Cancel As Integer)
If Me.OpenArgs <> "" Then 'It has been opened for new records only
CityName = Me.OpenArgs
End If
End Sub

I've tried this on the forms current event with added condition of
Me.NewRecord and with fully qualified name for CityName

The form opens OK but the field is always blank - when the trace passes through the CityName assignment though, it makes the assignment successfully according to the value shown on hovering over the variable in the VBA editor.

Any comments much appreciated
 
- try: Response = acDataErrContinue and put this before the DoCmd. (?)
- i sometimes get unexpected reactions when using acDialog. i would test removing that too...?
 
Use the Load event rather than the Open to set the CityName. I believe the Open event is too soon in the process.
 

Users who are viewing this thread

Back
Top Bottom