Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkbox to copy fields works - sort of

Status
Not open for further replies.

thefourthwall

IS-IT--Management
Feb 26, 2002
387
US
I created a form for users who drop off pc's to be repaired.

Sometimes the person dropping off the pc is not the owner, and to capture that, I have "Contact" and "Drop Off Person" fields and a checkbox that, when checked, copies certain "Contact" fields' values to corresponding "Drop Off Person" fields.

One oddity, however: the "drop off" phone number field does not show as updated after clicking the checkbox, unless I tab through the fields. Same for clearing the checkbox.

I have compared the data format, field sizes, input masks, and so on, and have come up empty.

Why is this happening?

Below is the on_click event code behind the checkbox; it probably is kludgy, if you have any suggestions around cleaning it up, I want to learn.

Thanks for your help.

Code:
Private Sub CheckCntctYesNo_Click()
If Me!CheckCntctYesNo Then
    Me!DropOff_User_Rank = Me!User_Rank
    Me!DropOff_First_Name = Me!Contact_First_Name
    Me!DropOff_Last_Name = Me!Contact_Last_Name
    Me!DropOff_Phone = Me!Phone
    Me!DropOffTZS = Me!ContactTZS
Else
    Me!DropOff_User_Rank = ""
    Me!DropOff_First_Name = ""
    Me!DropOff_Last_Name = ""
    Me!DropOff_Phone = ""
    Me!DropOffTZS = ""
End If
End Sub
 
Maybe a dumb question, but are the fields all named as they are on the form?

However, I suggest not duplicating the info into additional fields if it's not necessary (i.e. it's the same). What if some of the data changes, then how would you copy the updated data into the 2nd field? I guess you could just type it, but why not just have a check-box that says "Drop-Off same as Contact" then on any reports/forms/queries for Drop-Off Info, you simply display the Contact Info if that box is checked, and display the Drop-Off info if it is not checked.

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Not a dumb question, they are all named as they are on the form. Do you see a naming problem I might have missed?

I thought about that too for reports, and was told that both sets of information need to actually be on the form...
 
Is it a data-entry form, or a "let me look up this info so i can call the person" form?

If #1, not an issue. Don't see the reason for it.
If #2, just display it as we said earlier.

Me!DropOff_User_Rank: iif(Me!CheckCntctYesNo=True,Me!User_Rank,Me!DropOff_User_Rank)

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Ginger,
It is a data entry form. Thanks for your information, I appreciate it.
 
dhookum,

Why Null rather than "" ?

It's not the only field with an input mask; most of the fields have one. The two phone fields have identical masks,
and I have tried it with the mask removed from both the form and table, without success . . .

this is rather bizarre...
 
Is the phone, the last control you enter into prior to checking the box? Does the order make any difference?

I generally don't allow zero-length-strings in my fields. Using Null rather than "" seems cleaner and truer to me.

Duane
Hook'D on Access
MS Access MVP
 
dhookom-

No, phone is not the last control prior to checking the box. The order in the contact fields is rank, fname, lname, helpdesk ticket number, phone number, tzs# and then checkbox.

In the dropoff fields, the order is fname, lname, phone, tzs#.

Thanks for the info re: zero-length-strings in fields. I'm still rather new to database design, but my experience so far has me hooked - the experience so far has been enlightening.
 
I would try move the code to the After Update rather than the click event. This might not make any difference but I don't like programming from the click event.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top