-
I have two forms, I declare a variable as public in the general decleration. In one form I give that variable a value, in the second form I have a select statment using that variable, but it doesn't hold the value. EX: Public phase as string......phase="PRI"...."Select unit from table where ph=phase"
-
<?>
Public in a form pertains to all within that form.
Public in a .bas module is across all forms.
Or
Public in a form like this.
Form2.text1 = form1.myVariable
-
I did put my public statement in the .bas module. In my second form I have something like(phhold=form1.myvar) that works, when I debug the value is there. But on my select statement it doesn't. I got an error messageinvalid column name. If I hard code it in my select statement it works. Maybe my syntex is off, could someone show me how they would write the select statment using the variable in the where clause...THANX
-
<?>
easiest if you post your code so one can see what is happening.
-
Your sql statement needs to look somthing like this:
"Select unit from table where ph=" & phase
If phase is a string, do this:
"Select unit from table where ph='" & phase & "'"
Hope it works...
-
Module (module.bas)
(general) (declarations)
Public phasehold as string
***************************
FrmMain
(mnuprimary) (click)
phasehold="Pri"
********************************
form2
Public Sub Form_Load()
Dim phhold As String
Dim sphase As String
Dim ssql As String
phhold = phasehold (phhold does show "pri" as its value)
Adodc1.Refresh
ssql = "select unit from units where units.phase = phhold"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = ssql
Adodc1.Refresh
Dim texttotal As Double
End Sub
-
DeepestDish
Thanks that was it, I didn't have the right syntex for the variable in the statement.