Display text value and label caption outlook vba (1 Viewer)

aman

Registered User.
Local time
Yesterday, 21:08
Joined
Oct 16, 2008
Messages
1,250
Hi Guys

I am writing the following code on the OK button of the outlook form. Actually I want to display the value stored in a textbox and caption of a label. But when I run the form and click OK then it doesn't display anything for the texbox and label caption.

It's really strange. I have stored a value in txtAccount1 but when I try to display the value using a message box then the message box says blank.

Code:
Private Sub btnOK_Click()
Me.txtHidden.SetFocus
Call MortgageNoValidation_New
End Sub

Code:
Public Sub MortgageNoValidation_New()
Dim StrMortgageNo As String
Dim StrErrorDescription As String
Dim Response As Integer

'StrErrorDescription = "OK"
' Reg Exp object to check that the mortgage numbers is 10 digits
Dim oRegEx As RegExp
MsgBox frmMessage.txtAccount1.Value
MsgBox frmMessage.lblSubject.Caption
 

Gasman

Enthusiastic Amateur
Local time
Today, 05:08
Joined
Sep 21, 2011
Messages
14,369
Do you have Option Explicit in the module.?

Where is MortgageNoValidation_New located.?

Pass the form reference to MortgageNoValidation_New if it is not in the form, which I suspect it is not, else you would have used Me.

Essentially hows is MortgageNoValidation_New supposed to know about the form controls?
 

aman

Registered User.
Local time
Yesterday, 21:08
Joined
Oct 16, 2008
Messages
1,250
MortgageNoValidation_New is located in a module.
 

aman

Registered User.
Local time
Yesterday, 21:08
Joined
Oct 16, 2008
Messages
1,250
Thanks Gasman, ANother question I have is around validating multiple account numbers.

This code works when there is one account number only (txtAccount1)but if there are multiple account numbers stored in multiple textboxes then how can I use the same function MortgageNoValidation_New on that? Do we need to use loop ? The other account numbers are stored in textboxes like txtAccount2,txtAccount3 and txtAccount4 ? So basically the user can store maximum 4 account numbers.

Thanks
 

Gasman

Enthusiastic Amateur
Local time
Today, 05:08
Joined
Sep 21, 2011
Messages
14,369
Call the routine with each account number, though by your naming, it sounds like the structure is incorrect and each account would be a separate record.?

However if you pass the form reference, then you can check any of it's controls in that sub.?

Not done it myself, but presumably you can adjust the properties of the controls on the form from it as well.?
 

Users who are viewing this thread

Top Bottom