After Update Field Not Working

Suzanne Joy

Registered User.
Local time
Today, 04:48
Joined
Jan 23, 2004
Messages
11
I have premisis information and contact information and want the premisis information to automatically default into the contact text boxes. This is working well for all fields, but the State field. I've attached the code. What am I doing wrong?

Private Sub Contact_Last_Name_AfterUpdate()
Me.Contact_Last_Name = DLook("[Prem_Name]", "GDB_Prem", "[Contact_Last_Name]= '& Forms![frmGDB_PREM]![Contact_Last_Name]'")

End Sub

Private Sub Prem_Name_DblClick(Cancel As Integer)
If Nz(Me.Contact_Last_Name, "") = "" Then
Me.Contact_Last_Name = Me.Prem_Name
End If

End Sub

Private Sub Prem_Name_Enter()
If Nz(Me.Contact_Last_Name, "") = "" Then
Me.Contact_Last_Name = Me.Prem_Name
End If

End Sub

Private Sub Prem_Name_Exit(Cancel As Integer)
If Nz(Me.Contact_Last_Name, "") = "" Then
Me.Contact_Last_Name = Me.Prem_Name
End If

End Sub

Private Sub Prem_Address_DblClick(Cancel As Integer)
If Nz(Me.Contact_Address, "") = "" Then
Me.Contact_Address = Me.Prem_Address
End If

End Sub

Private Sub Prem_Address_Enter()
If Nz(Me.Contact_Address, "") = "" Then
Me.Contact_Address = Me.Prem_Address
End If

End Sub

Private Sub Prem_Address_Exit(Cancel As Integer)
If Nz(Me.Contact_Address, "") = "" Then
Me.Contact_Address = Me.Prem_Address
End If

End Sub

Private Sub Prem_Address2_Click()
If Nz(Me.Contact_Address2, "") = "" Then
Me.Contact_Address2 = Me.Prem_Address2
End If

End Sub

Private Sub Prem_Address2_Exit(Cancel As Integer)
If Nz(Me.Contact_Address2, "") = "" Then
Me.Contact_Address2 = Me.Prem_Address2
End If

End Sub

Private Sub Prem_City_Click()
If Nz(Me.Contact_City, "") = "" Then
Me.Contact_City = Me.Prem_City
End If
End Sub

Private Sub Prem_City_Exit(Cancel As Integer)
If Nz(Me.Contact_City, "") = "" Then
Me.Contact_City = Me.Prem_City
End If
End Sub

Private Sub Prem_State_Click()
If Nz(Me.Contact_State, "") = "" Then
Me.Contact_State = Me.Prem_State
End If

End Sub

Private Sub Prem_State_Exit(Cancel As Integer)
If Nz(Me.Contact_State, "") = "" Then
Me.Contact_State = Me.Prem_State
End If

End Sub
 
Why not set the default property of the field and remove all the code?

ex:
[Contact_State] Default Value= [Prem_State]
 
Thank you, Stormin_norm, but that didn't seem to work. I had tried that before I created all the code, but was willing to try it again. Any suggestions? I've attached the .mdb (zipped), if you'd like to look at my form. Go to frmGDB_Prem. Pls. excuse the messy format -- I am still designing the form.

Suz.
 
Sorry didn't see the db attached. Can you upload it again.
 
Sorry - It looks as if I can't get my .zip file small enough to post here. I appreciate the help, though.

Suz.
 
No problem...
Watch for spaces in field names.
If it is Prem*SPACE*State then make sure the default property = [Prem Name] and not [Prem_Name]

When you are in table design view what is the name of the field? With underscore or with space?
 
The field name is definitely Prem_State. Thanks again for your willingness to help!

Suz.
 
Can you outline the table structure, cut&paste query which is used for the form. Describe or give a screen shot of the form?
 
Please see attached. Let me know if this is not what you're looking for.
 

Attachments

  • gdb_screencapt.jpg
    gdb_screencapt.jpg
    44.2 KB · Views: 125
How 'bout something like this (see attached DB):

Private Sub Prem_Name_AfterUpdate()
If IsNull(Me![Contact_Name]) Then
Me![Contact_Name] = Me![Prem_Name]
End If
End Sub


-- This assumes you want it to populate the contact fields after entering "something" in the 'prem' fields. Do the same for state, address, etc...
REMOVE all the double click and click code you had.

BTW- bmp was TINY and tough to read. Next time split it in two.
 

Attachments

It did the job! Thank you SO much! I also removed all the click code and will take your advice the next time I post a .jpg.

Thanks again and have a great day, Suz.
 

Users who are viewing this thread

Back
Top Bottom