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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HudsonMarineAuthor Commented:
this works! Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.