OPen Password form

amna77

Active Member
Joined
May 9, 2002
Messages
251
Hi, i have one form, on which I have combo boxes and date fields. like 7 of each.

Combo1 and text1
Combo2 and text2

Now what I want to do is, when ever user click on the text1 then I it opens up the small paswword form. but the thing is I want to get that combo1 value on the small pop up form. if user clik on text2 then combo2 value should be caputre in that small pop up form.
Please help me with that. I shall be thankful to you.

Thanks
Amna
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
So I assume you have something like:
Code:
DoCmd.OpenForm "frmPwd"
To open your form. Try doing something like this:
Code:
Private Sub text1_Click()
    Dim lngSuffix as Long
    lngSuffix = 1  ' change for each text box (i.e., text2 should be 2)
    DoCmd.OpenForm FormName="frmPwd",OpenArgs=Me.Controls("Combo" & lngSuffix).Value
End Sub
Then in your password form, put something like this in the Open Event:
Code:
Me.SomeControl.Value = Me.OpenArgs

There are other ways of doing this, but this should work for you.

HTH,

Russell
 
Upvote 0
Hi Russell, Thanks for the quick response. I am getting little error. like "Invalid NUll" some thing like that. I don't know why is that. Can I have your e-mail ddress so I can send you my small database for your review.

Thanks
Amna
 
Upvote 0
i am not using MSOutLook. as a default on my computer it goes to Outlook, and my outlook does not open. So can't even see your e-mail address so I can send you e-mail from yahoo.
 
Upvote 0
Ok, after looking at your database, I made a few changes to the names of your text- and comboboxes.. Also, where I had FormName="frmPwd" below, I should have had FormName:="frmPwd".

Back to the names. I named the ComboBoxes:

cboQualNames
cboPMNames
cboEngNames
cboEstimNames
cboPurchNames
cboProdNames

and the TextBoxes:

txtQualNames
txtPMNames
txtEngNames
txtEstimNames
txtPurchNames
txtProdNames

The reason for this is so that we can tie the clicking of the textbox to the corresponding combo box. If you think that this naming is "anal", you won't after you've worked with lots of code and you can't tell one control from another by its name.

Ok, so then I wrote a general procedure that will open your password form. It takes advantage of Screen.ActiveControl, which is the Active Control (the control that has the focus) on the form. It looks like this:
Code:
Private Sub OpenPwd()
    Dim lngSuffix As Long
    Dim strComboName As String
    Dim strOpenArgs As String
    
    strComboName = Screen.ActiveControl.Properties("Name")
    
    strComboName = Left(strComboName, InStr(strComboName, "Date") - 1)
    
    strComboName = "cbo" & Mid(strComboName, 4) & "Names"
    
    strOpenArgs = Me.Controls(strComboName).Value
    DoCmd.OpenForm FormName:="frmPassword", OpenArgs:=strOpenArgs
End Sub
This is in the the form's class module. Ok, then all you need to do is to put something like this in each "Date" TextBox's On Click (or maybe even On Enter) event, something like this:
Code:
Private Sub txtQualDate_Click()
    Call OpenPwd
End Sub

Private Sub txtPMDate_Click()
    Call OpenPwd
End Sub

'etc.

Make sense? Hope so - let me know if not!

-Russell
 
Upvote 0
Russell , Thankyou, thankyou, thankyou. you are great man. Thanks for helping me. YOu are the best.
Once again, thanks
 
Upvote 0
sorry to bother you again, you know when I click on that date. it suppose to open frmpwd, but it gave me error, like sub or function not defiiend. and it higlight the following codes.

Private Sub txtQualDate_DblClick(Cancel As Integer)
Call OpenPwd

Whats wrong now? Do you whats wrong with those codes?
Thanks for heling me out

Thanks
 
Upvote 0
Where did you put the code "OpenPwd"? It should be in the form's module...if it is, paste all the code from your module (use
Code:
code here
so that it will be easier on the eyes, if you don't mind).

-rh
 
Upvote 0

Forum statistics

Threads
1,221,531
Messages
6,160,357
Members
451,642
Latest member
mirofa

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