Variable expected

  • Thread starter Jean-Paul De Winter
  • Start date
J

Jean-Paul De Winter

Hi,

I am struggeling with programming a module.
I wrote:

Private Sub Keuzelijst0_Click()

On Error GoTo einde
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE Patienten SET Patienten.punten = False WHERE
Patienten.punten=True;"
DoCmd.SetWarnings True
Me!LK = Me!Keuzelijst0
Me!Periode = Empty
Me!ll = Empty
Me!Vak = Empty
Dim strWhere As String
With Forms![rapporten ingeven]
strWhere = "([lk])='" & Forms![rapporten ingeven]![Keuzelijst0] &
"'"
End With
Me.[subform_rapporten_vak].Form.Filter = strWhere
Me.[subform_rapporten_vak].Form.FilterOn = True
einde:
Stagecontrole

end sub

Stagecontrole is the name of a module:


Public Function Stagecontrole()
Me.Invulstage = "Ja"
Me.Bijschrift69.Visible = True
Me.Stage.Visible = True
Me.stage_ZG1.Visible = True
Me.stage_ZG2.Visible = True
Me.stage_G1.Visible = True
Me.stage_G2.Visible = True
Me.stage_V1.Visible = True
Me.stage_V2.Visible = True
Me.stage_OV1.Visible = True
Me.stage_OV2.Visible = True
Me.stage_GN1.Visible = True
Me.stage_GN2.Visible = True
Me.S_opmerking.Visible = True

End Function


When I click on "keuzelijst0" I get an errormessage saying (and now I have
to translate)

a variable or procedure is expected, not a module
The message appears on the line with "Stagecontrole"
What am I doing worng?

Whe I put the function-code in the code of the form itself it works perfect
but not when I create a seperate module.

Thanks for your kind help.
JP
 
B

Brian

Jean-Paul De Winter said:
Hi,

I am struggeling with programming a module.
I wrote:

Private Sub Keuzelijst0_Click()

On Error GoTo einde
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE Patienten SET Patienten.punten = False WHERE
Patienten.punten=True;"
DoCmd.SetWarnings True
Me!LK = Me!Keuzelijst0
Me!Periode = Empty
Me!ll = Empty
Me!Vak = Empty
Dim strWhere As String
With Forms![rapporten ingeven]
strWhere = "([lk])='" & Forms![rapporten ingeven]![Keuzelijst0] &
"'"
End With
Me.[subform_rapporten_vak].Form.Filter = strWhere
Me.[subform_rapporten_vak].Form.FilterOn = True
einde:
Stagecontrole

end sub

Stagecontrole is the name of a module:


Public Function Stagecontrole()
Me.Invulstage = "Ja"
Me.Bijschrift69.Visible = True
Me.Stage.Visible = True
Me.stage_ZG1.Visible = True
Me.stage_ZG2.Visible = True
Me.stage_G1.Visible = True
Me.stage_G2.Visible = True
Me.stage_V1.Visible = True
Me.stage_V2.Visible = True
Me.stage_OV1.Visible = True
Me.stage_OV2.Visible = True
Me.stage_GN1.Visible = True
Me.stage_GN2.Visible = True
Me.S_opmerking.Visible = True

End Function


When I click on "keuzelijst0" I get an errormessage saying (and now I have
to translate)

a variable or procedure is expected, not a module
The message appears on the line with "Stagecontrole"
What am I doing worng?

Whe I put the function-code in the code of the form itself it works perfect
but not when I create a seperate module.

Thanks for your kind help.
JP

You can't call a module, you can only call functions and procedures INSIDE
the module. Change the name of the module to something else (anything, it
doesn't matter), then VBA will be able to find the function Stagecontrole
that is IN the module.
 
J

Jean-Paul De Winter

OK, this seems to be correct but...
I get problems with the "Me!"
I changed it to the forms name from where it is called from
example: Me.Invulstage = "Ja" becomes: [Rapprten
ingeven$.invulstage = "Ja"
but this gave me following error:
an external name is not defined

Whta to do?
Thanks

Brian said:
Jean-Paul De Winter said:
Hi,

I am struggeling with programming a module.
I wrote:

Private Sub Keuzelijst0_Click()

On Error GoTo einde
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE Patienten SET Patienten.punten = False WHERE
Patienten.punten=True;"
DoCmd.SetWarnings True
Me!LK = Me!Keuzelijst0
Me!Periode = Empty
Me!ll = Empty
Me!Vak = Empty
Dim strWhere As String
With Forms![rapporten ingeven]
strWhere = "([lk])='" & Forms![rapporten ingeven]![Keuzelijst0] &
"'"
End With
Me.[subform_rapporten_vak].Form.Filter = strWhere
Me.[subform_rapporten_vak].Form.FilterOn = True
einde:
Stagecontrole

end sub

Stagecontrole is the name of a module:


Public Function Stagecontrole()
Me.Invulstage = "Ja"
Me.Bijschrift69.Visible = True
Me.Stage.Visible = True
Me.stage_ZG1.Visible = True
Me.stage_ZG2.Visible = True
Me.stage_G1.Visible = True
Me.stage_G2.Visible = True
Me.stage_V1.Visible = True
Me.stage_V2.Visible = True
Me.stage_OV1.Visible = True
Me.stage_OV2.Visible = True
Me.stage_GN1.Visible = True
Me.stage_GN2.Visible = True
Me.S_opmerking.Visible = True

End Function


When I click on "keuzelijst0" I get an errormessage saying (and now I have
to translate)

a variable or procedure is expected, not a module
The message appears on the line with "Stagecontrole"
What am I doing worng?

Whe I put the function-code in the code of the form itself it works perfect
but not when I create a seperate module.

Thanks for your kind help.
JP

You can't call a module, you can only call functions and procedures INSIDE
the module. Change the name of the module to something else (anything, it
doesn't matter), then VBA will be able to find the function Stagecontrole
that is IN the module.
 
J

Jean-Paul De Winter

how dumb... found the solution...
forgot to add [forms]!
[Rapprten ingeven].invulstage = "Ja"
should be
[forms]![Rapprten ingeven]!invulstage

Thank you all
JP

Jean-Paul De Winter said:
OK, this seems to be correct but...
I get problems with the "Me!"
I changed it to the forms name from where it is called from
example: Me.Invulstage = "Ja" becomes: [Rapprten
ingeven$.invulstage = "Ja"
but this gave me following error:
an external name is not defined

Whta to do?
Thanks

Brian said:
Jean-Paul De Winter said:
Hi,

I am struggeling with programming a module.
I wrote:

Private Sub Keuzelijst0_Click()

On Error GoTo einde
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE Patienten SET Patienten.punten = False WHERE
Patienten.punten=True;"
DoCmd.SetWarnings True
Me!LK = Me!Keuzelijst0
Me!Periode = Empty
Me!ll = Empty
Me!Vak = Empty
Dim strWhere As String
With Forms![rapporten ingeven]
strWhere = "([lk])='" & Forms![rapporten
ingeven]![Keuzelijst0]
&
"'"
End With
Me.[subform_rapporten_vak].Form.Filter = strWhere
Me.[subform_rapporten_vak].Form.FilterOn = True
einde:
Stagecontrole

end sub

Stagecontrole is the name of a module:


Public Function Stagecontrole()
Me.Invulstage = "Ja"
Me.Bijschrift69.Visible = True
Me.Stage.Visible = True
Me.stage_ZG1.Visible = True
Me.stage_ZG2.Visible = True
Me.stage_G1.Visible = True
Me.stage_G2.Visible = True
Me.stage_V1.Visible = True
Me.stage_V2.Visible = True
Me.stage_OV1.Visible = True
Me.stage_OV2.Visible = True
Me.stage_GN1.Visible = True
Me.stage_GN2.Visible = True
Me.S_opmerking.Visible = True

End Function


When I click on "keuzelijst0" I get an errormessage saying (and now I have
to translate)

a variable or procedure is expected, not a module
The message appears on the line with "Stagecontrole"
What am I doing worng?

Whe I put the function-code in the code of the form itself it works perfect
but not when I create a seperate module.

Thanks for your kind help.
JP

You can't call a module, you can only call functions and procedures INSIDE
the module. Change the name of the module to something else (anything, it
doesn't matter), then VBA will be able to find the function Stagecontrole
that is IN the module.
 
Top