Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error: Variable not defined

Status
Not open for further replies.

awosusba

Programmer
Oct 2, 2006
3
0
0
DE
Can anyone tell me what is going wrong?
My code consists partly the following statements:
.
.
.
Sub Dialog_Run(ByVal FormName As String)
Select Case FormName
Case "Aufzug_HQ_GG"
Range("AufzNr") = Aufzug_HQ_GG.AufzNrBox.Value
Range("HQ") = Aufzug_HQ_GG.HQ_Box.Value
Range("GG") = Aufzug_HQ_GG.GG_Box.Value
Range("GU") = Aufzug_HQ_GG.GU_Box.Value
Range("GH") = Aufzug_HQ_GG.GH_Box.Value
Range("FM") = Aufzug_HQ_GG.FM_Box.Value
Aufzug_HQ_GG.Show
'
Case "Aux_Daten"
Range("xFP") = Aux_Daten.xFP_Box.Value
Range("yFP") = Aux_Daten.yFP_Box.Value
Range("Xecc") = Aux_Daten.XeccBox.Value
Range("Yecc") = Aux_Daten.YeccBox.Value
Aux_Daten.Show
'
Case "Cwt_Abmasse"
Range("TG") = Cwt_Abmasse.TG_Box.Value
Range("BG") = Cwt_Abmasse.BG_Box.Value
Range("HGF") = Cwt_Abmasse.HGF_Box.Value
Range("HFg") = Cwt_Abmasse.HFg_Box.Value
Cwt_Abmasse.Show
'

Case "GU_GH_XYCoord"
Range("xGH") = GU_GH_XYCoord.xGH_Box.Value
Range("yGH") = GU_GH_XYCoord.yGH_Box.Value
Range("xGU") = GU_GH_XYCoord.xGU_Box.Value
Range("yGU") = GU_GH_XYCoord.yGU_Box.Value
Range("xGUS") = GU_GH_XYCoord.xGUS_Box.Value
Range("yGUS") = GU_GH_XYCoord.yGUS_Box.Value
GU_GH_XYCoord.Show
'
End Select
End Sub

"Aufzug_HQ_GG", "Aux_Daten", "Cwt_Abmasse", "GU_GH_XYCoord"
are forms:
When I run the code I get "Compile error: variable not defined" on line ...Range("TG") = Cwt_Abmasse.TG_Box.Value
Obviously "Cwt_Abmasse" has not been recognized as a form!
Who knows the remedy ???
The code runs without error if all lines with
Range("...") = Cwt_Abmasse....Value are commented.
 
Have you definitely got a range named TG?

If you haven't this would definitely throw up an error.



Hope this helps.

Matt
[rockband]
 
Have you added Option Explicit to General Declarations?
 
Thank you CHANDLM,
Yes "TG", "BG", "HGF" and "HFg" are defined names.
As I stated, it seams the name of the FORM -
Cwt_Abmasse - is the culprit!

As to the suggestion of ETTIENNE:
Yes Option Explicit is included in the General Declarations.
 

Thsn, it looks like you do not have TG_Box (whatever that is) on your Form Cwt_Abmasse

Have you consider:
Code:
Sub Dialog_Run(ByVal FormName [blue]As Form[/blue])
  Select Case FormName[blue].Name[/blue]
  Case "Aufzug_HQ_GG"
    Range("AufzNr") = [blue]FormName[/blue].AufzNrBox.Value
    Range("HQ") = [blue]FormName[/blue].HQ_Box.Value
    Range("GG") = [blue]FormName[/blue].GG_Box.Value
    Range("GU") = [blue]FormName[/blue].GU_Box.Value
    Range("GH") = [blue]FormName[/blue].GH_Box.Value
    Range("FM") = [blue]FormName[/blue].FM_Box.Value
    [blue]FormName[/blue].Show

...
And call it by:
Code:
Call Dialog_Run(Me)

Have fun.

---- Andy
 

The link
file://deu.schindler.com/DFSroot$/STS/shared/DEU/Temp/Awosusba/Cwt_GRails.xls

does not work (at least for me it doesn't) :-(

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top