RE: VBA Coding Error, DOH

philhowell

Board Regular
Joined
Jun 11, 2002
Messages
175
i'm running a simple form in access that updates a form text box with the users password when the users name is seleceted in a combo-box, but it throws up an error saying.........

run-time error 2465

i'm quite new to this so feel feel to give me any pointers

Thanks
Phil

*******************************
Below is the VBA code


Private Sub User_Change()

' define variables
Dim varX As Variant
Dim frmNewPWD
Dim frmUser
Dim frmOldPWD

frmUser = Form.ChangeLotusPWD.User.Value

varX = DLookup("[PWD]", "5_LotusPwds", "[UserName]= '" & frmUser & "'")

If IsNull(varX) Then
varX = " "
Else
End If

' update users password so it display the relevant one based on the user name selected
Forms.ChangeLotusPWD.OLDPWD.Value = varX

' ensure that the New password text box on the form is empty
Forms.ChangeLotusPWD.NEW_PWD.Value = " "

End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
4got to say that it throws up the error on the line

frmUser = Form.ChangeLotusPWD.User.Value

saying it can't define it........

:(
 
Upvote 0
If this code is all behind one form (it looks like it is), and if your combo box is named "User", then you can do something like this:

varX = Me.User

(Value is the default item for a combo box, so you don't need the .Value...but you can add it if you like - it never hurts).

HTH,

Russell
 
Upvote 0
It would have worked had you changed:

frmUser = Form.ChangeLotusPWD.User.Value


To:

frmUser = Forms!ChangeLotusPWD.User.Value

-rh
 
Upvote 0

Forum statistics

Threads
1,221,510
Messages
6,160,226
Members
451,632
Latest member
purpleflower26

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top