Checkbox and If Statement (1 Viewer)

Teebird

Registered User.
Local time
Tomorrow, 04:57
Joined
Sep 3, 2006
Messages
60
Hi All

I have a residential address and a postal address on my form. What I want to do is when the user completes the 3 fields from the Residential Address Eg: Address, State, Postcode and then ticks the checkbox (Residential Address is Postal Address), the information previously entered will automatically fill the same fields in the Postal Address.

If Checkbox1 = true then
RAddress = PAddress
RState = PState
RPostcode - PPostcode
End If

I just can't work out the correct code.

Many thanks for any help.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 12:27
Joined
Aug 30, 2003
Messages
36,134
It appears you have it reversed. Try:

Me.PAddress = Me.RAddress
 

Teebird

Registered User.
Local time
Tomorrow, 04:57
Joined
Sep 3, 2006
Messages
60
Excellent thanks for that. Here is my code now.

Code:
Private Sub chkResPostal_AfterUpdate()

If chkResPostal = True Then
    Me.[PO Box] = Me.RAddress
    Me.PCity = Me.RCity
    Me.PState = Me.RState
    Me.PPostcode = Me.RPostCode
    
    Else: chkResPostal = ""

End If

End Sub

Except it is only updating the City and Postcode fields right away then after I close the form it updates the other 2 fields. How can I speed this up?
 

Teebird

Registered User.
Local time
Tomorrow, 04:57
Joined
Sep 3, 2006
Messages
60
Update - I changed my code to this - that fixes the problem of it updating the field slowly but now my checkbox remains true for each member as I move from one member to another via the form nagivation arrows.

Code:
Private Sub chkResPostal_AfterUpdate()

If chkResPostal = True Then
    Me.[PO Box] = Me.RAddress
    Me.PCity = Me.RCity
    Me.PState = Me.RState
    Me.PPostcode = Me.RPostCode
    
    Else: chkResPostal = False
End If

Me.Notes.SetFocus

End Sub

Do I need some sort of requery on the form now?
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 12:27
Joined
Aug 30, 2003
Messages
36,134
Is the checkbox bound to anything in the table? If not, which is what it sounds like, you can set it as desired in the current event, which occurs when you change records.
 

Teebird

Registered User.
Local time
Tomorrow, 04:57
Joined
Sep 3, 2006
Messages
60
:) excellent just what I wanted - many thanks. and yes my checkbox was unbound.
 

Users who are viewing this thread

Top Bottom