What am I doing wrong????

nyrob609

Registered User.
Local time
Yesterday, 20:37
Joined
May 22, 2009
Messages
46
Need some assistance!!

I have a main form that has a subform that will be use to verify insurance information. I have instructed the staff once is verified to indicate in the field [Insurance Verified] "Yes".

I want for a msg box to come up when I click the close form if the field is missing the data. I put the code below at first it wasn't working because it couldn't find it. I added the word Subform in front of the form name and field. Now is telling me that an object is required. What am I doing wrong.

Private Sub Command27_Click()
On Error GoTo Err_Command27_Click
If IsNull(SubForm![Z_Authorizationform]![Insurance Verified]) Then
MsgBox "If Insurance information was verified please indicate Yes"
DoCmd.GoToControl (SubForm![Z_Authorizationform].[Insurance Verified])

DoCmd.Close

End If
Exit_Command27_Click:
Exit Sub
Err_Command27_Click:
MsgBox Err.Description
Resume Exit_Command27_Click

End Sub
 
I added the word Subform in front of the form name and field

Hi,

you are nearly there.

your code-
Code:
Private Sub Command27_Click()
On Error GoTo Err_Command27_Click
If IsNull(SubForm![Z_Authorizationform]![Insurance Verified]) Then
MsgBox "If Insurance information was verified please indicate Yes"
DoCmd.GoToControl (SubForm![Z_Authorizationform].[Insurance Verified])

DoCmd.Close

End If
Exit_Command27_Click:
Exit Sub
Err_Command27_Click:
MsgBox Err.Description
Resume Exit_Command27_Click

End Sub

should look a bit like this-
Code:
Private Sub Command27_Click()
On Error GoTo Err_Command27_Click
If IsNull([COLOR="Red"]me![/COLOR]SubForm![Z_Authorizationform]![Insurance Verified]) Then
MsgBox "If Insurance information was verified please indicate Yes"
me!Subform![Z_Authorizationform].[Insurance Verified][COLOR="red"].SetFocus[/COLOR]
End If
DoCmd.Close


Exit_Command27_Click:
Exit Sub
Err_Command27_Click:
MsgBox Err.Description
Resume Exit_Command27_Click

End Sub

Targeting subforms & sub subforms gos in the order of

MainForm!Subform!SubSubform!SubSubSubFormETC!FormControl

if you have typed the correct path, the intellisense will kick in and offer the available operations.


NS
 
if you have typed the correct path, the intellisense will kick in and offer the available operations.
only if you use the DOT and not the BANG (!) between the items :D
 
only if you use the DOT and not the BANG (!) between the items

Ha Haaa. you're dead right ( well, mostly.....)

Me!MyForm!MySubForm!MyObject. will also bring up the available properties for the object, it just wont show the available objects


Nigel :p
 
You could also use:

Me.Z_Authorizationform.Form.Insurance_Verified
 
Quick solution to references > getting them right every time

Open the form you wish to reference.
Open a query .. any query
In any field right click and select Build
In the menus on the left click forms >> Open forms >>find your form and select it >>find your control and select it .. click paste. Ta Da your reference is now in the build window above copy and paste it into your code.
 
Thank you all for your help!

I got as far as getting the Message Box but it won't go to the control Field. It gives message "an expression you entered is the wrong data type for one of the arguments"


If IsNull(Me.Form![Z_VerificationInsuranceForm]![Z_Authorizationform]![Insurance Verified]) Then
MsgBox "Insurance must be verified once the information has verified please Indicate Yes on field"
DoCmd.GoToControl (Me.Form![Z_VerificationInsuranceForm]![Z_Authorizationform]![Insurance Verified])
End If
DoCmd.Close
 
Hi Rob

again -

Code:
If IsNull(Me.Form![Z_VerificationInsuranceForm]![Z_Authorizationform]![Insurance Verified]) Then
MsgBox ("Insurance must be verified once the information has verified please Indicate Yes on field")
Me.Form![Z_VerificationInsuranceForm]![Z_Authorizationform]![Insurance Verified][COLOR="Red"].SetFocus[/COLOR]
End If
DoCmd.Close


regs


Nigel
 

Users who are viewing this thread

Back
Top Bottom