Making fields visible

mattkbishop

Registered User.
Local time
Today, 21:54
Joined
Mar 5, 2003
Messages
36
How do I do this?

Basically, I got a subform (and another field also) that are invisible. They become visible when a tick box is, well ticked.


Ok... so I have a button that does some nice code stuff. Well I have two actually....

What I want, is some code to put in the code builder bit, to make subform1 and field1 visible for the first button,

and then some more to make them invisible again for the second button, although they still have to be shown if the beforehand tick boxes are ticked, presumably the code on the tick box will sort that out. Anyone? Thankyou.
 
Well I had a play.... I got this code:

Forms![frmProfessionalInfo].SetFocus
frmtblLiteratureSubform.Visible = True

Forms![frmProfessionalInfo].SetFocus
ReceivedWritingPermission.Visible = True

Forms![frmProfessionalInfo].SetFocus
ReceivedTelPermission.Visible = True

to make them all visible when the button is pressed. That goes before the code:

' change to filter by form mode
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 0, 0, acMenuVer70

' open filter control form
Dim stDocName As String
Dim stLinkCriteria As String

' open filter control form
stDocName = "frm_FilterControl"
DoCmd.OpenForm stDocName, , , stLinkCriteria

------------
That works. BUT....

When I put

Forms![frmProfessionalInfo].SetFocus
frmtblLiteratureSubform.Visible = False

Forms![frmProfessionalInfo].SetFocus
ReceivedWritingPermission.Visible = False

Forms![frmProfessionalInfo].SetFocus
ReceivedTelPermission.Visible = False

in the buttons with the code:

Private Sub Command4_Click()

Forms![frmProfessionalInfo].SetFocus
DoCmd.RunCommand acCmdClearGrid

' set focus to form to filter
Forms![frmProfessionalInfo].SetFocus
' apply filter
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 2, , acMenuVer70

Forms![frm_FilterControl].SetFocus
DoCmd.Close



End Sub
--------
and
--------

Private Sub cmdRemoveFilter_Click()

' close the Filter Control From
DoCmd.Close

' set focus to form that has filter
Forms![frmProfessionalInfo].SetFocus
' remove filter
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 3, , acMenuVer70

End Sub
--------

but I keep getting the error:

Compile Error:

Variable no defined.


Eh? The error is on the

frmtblLiteratureSubform.

ReceivedWritingPermission.

ReceivedTelPermission.

bits. Why is it not working on those (the field and subform names?) when it does on the other bit that works?
 
The help menu says:



You use the Option Explicit statement to protect your modules from having undeclared variables and to eliminate the possibility of inadvertently creating new variables when typographical errors occur. This error has the following cause and solution:

· You used an Option Explicit statement to require the explicit declaration of variables, but you used a variable without declaring it.

Explicitly declare the variable, or change the spelling of the variable to match that of the intended variable.



Eh? :(
 
Hi there,

The reason why you are getting this error is that Access is looking for variables called:

frmtblLiteratureSubform
ReceivedWritingPermission
ReceivedTelPermission

If they are not declared i.e. Dim myVar as String etc. then Access throws a compile error 'Variable Not Defined'. The option explicit means that all variables have to be declared. Reading your code, you are trying to reference subforms and their controls. Have a look at this thread where you can download a word document that tells you the syntax for referencing subforms and their controls.

HTH
Rob
 

Users who are viewing this thread

Back
Top Bottom