How to approach setting owner and assigned to field to Administrator with one button click?

See provided Pic:

I have a form with company info in it and a subform with that companies contacts - I wish to select a contact and then set the Assigned To and the Owner fields to Administrator with one easy click - can someone help me solve this?

I was thinking of using a different form for this particular function but im not sure if there is an easier way using this existing form?

Thanks in advance.

 d
LVL 1
HudsonMarineAsked:
Who is Participating?
 
pteranodon72Commented:
Ok, just change the names of the textboxes:

Private Sub AssignedTo_DblClick(Cancel As Integer)
AssignedTo = "Administrator"
Owner = "Administrator"
End Sub

This only maps it to the double click in AssignedTo. You could put the same two lines in the Owner textbox's double-click if you want.

Also, add
Option Explicit
as the first line of your module. If that option was activated, the debugger would have caught "txtAssignedTo" and "txtOwner" as undeclared names. Without it, the debugger thinks that you have declared
Dim txtAssignedTo As Variant
Dim txtOwner As Variant

Keeping Option Explicit turned on helps a lot in finding typos in code.

Hope this helps,

pT72
0
 
pteranodon72Commented:
Open subform in design view. In the "Assigned To" textbox (I don't know its name) add a OnDoubleClick event. In the code attached to that event, add

txtAssigned_To = "Administrator"
txtOwner = "Administrator"

(but use the real textbox names).

Double-click is a good event for a change like this. Single-clicking a field is not enough- you'll click it while just reading the info.

If this kind of change is not appropriate everywhere the subform is used, you should create a separate subform.

HTH,
pT72
0
 
HudsonMarineAuthor Commented:
heres what i have

Private Sub AssignedTo_DblClick(Cancel As Integer)
txtAssignedTo = "Administrator"
txtOwner = "Administrator"
End Sub

but when i load the form and double click the assignedto or the owner field - nothing happens!
0
 
HudsonMarineAuthor Commented:
or it only highlights the value in the field. and it doesnt change the value to administrator.
0
 
HudsonMarineAuthor Commented:
this works! Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.