How do I reference an integer variable in a query? 
Author Message
 How do I reference an integer variable in a query?

I have the below code, in which I bind the recordsource of a grid
control to a query.
temp=0
temp=val(thisformset.form1.field1.value)
thisform.grid1.RecordSource = "SELECT * from table1 where table1.field1
= " + temp + " into cursor c1"
thisform.grid1.refresh()

I get the following error:"Function argument value, type, or count is
invalid"

It works in other instances when the variable temp is text.  It also
works when I replace line 3 with:

thisform.grid1.RecordSource = "SELECT * from table1 where table1.field1
= 9 into cursor c1"

If I remove the val() from the thisformset.form1.field1.value in line 2
of the original code, it gives me the following error:"Operator/operand
mismatch"

Thanks in advance.



Thu, 18 Jul 2002 03:00:00 GMT  
 How do I reference an integer variable in a query?
I have the below code, in which I bind the recordsource of a grid
control to a query.
temp=0
temp=val(thisformset.form1.field1.value)
thisform.grid1.RecordSource = "SELECT * from table1 where table1.field1
= " + temp + " into cursor c1"
thisform.grid1.refresh()

I get the following error:"Function argument value, type, or count is
invalid"

It works in other instances when the variable temp is text.  It also
works when I replace line 3 with:

thisform.grid1.RecordSource = "SELECT * from table1 where table1.field1
= 9 into cursor c1"

If I remove the val() from the thisformset.form1.field1.value in line 2
of the original code, it gives me the following error:"Operator/operand
mismatch"

Thanks in advance.



Thu, 18 Jul 2002 03:00:00 GMT  
 How do I reference an integer variable in a query?
I have the below code, in which I bind the recordsource of a grid
control to a query.
temp=0
temp=val(thisformset.form1.field1.value)
thisform.grid1.RecordSource = "SELECT * from table1 where table1.field1
= " + temp + " into cursor c1"
thisform.grid1.refresh()

I get the following error:"Function argument value, type, or count is
invalid"

It works in other instances when the variable temp is text.  It also
works when I replace line 3 with:

thisform.grid1.RecordSource = "SELECT * from table1 where table1.field1
= 9 into cursor c1"

If I remove the val() from the thisformset.form1.field1.value in line 2
of the original code, it gives me the following error:"Operator/operand
mismatch"

Thanks in advance.



Thu, 18 Jul 2002 03:00:00 GMT  
 How do I reference an integer variable in a query?
My news server wasn't displaying them.
Quote:

> I have the below code, in which I bind the recordsource of a grid
> control to a query.
> temp=0
> temp=val(thisformset.form1.field1.value)
> thisform.grid1.RecordSource = "SELECT * from table1 where table1.field1
> = " + temp + " into cursor c1"
> thisform.grid1.refresh()

> I get the following error:"Function argument value, type, or count is
> invalid"

> It works in other instances when the variable temp is text.  It also
> works when I replace line 3 with:

> thisform.grid1.RecordSource = "SELECT * from table1 where table1.field1
> = 9 into cursor c1"

> If I remove the val() from the thisformset.form1.field1.value in line 2
> of the original code, it gives me the following error:"Operator/operand
> mismatch"

> Thanks in advance.



Thu, 18 Jul 2002 03:00:00 GMT  
 How do I reference an integer variable in a query?
You need to keep the key value as a character for the string creation
Just dump the "VAL()" when creating m.temp

HTH Jeremy

Quote:

> I have the below code, in which I bind the recordsource of a grid
> control to a query.
> temp=0
> temp=val(thisformset.form1.field1.value)
> thisform.grid1.RecordSource = "SELECT * from table1 where table1.field1
> = " + temp + " into cursor c1"
> thisform.grid1.refresh()

> I get the following error:"Function argument value, type, or count is
> invalid"

> It works in other instances when the variable temp is text.  It also
> works when I replace line 3 with:

> thisform.grid1.RecordSource = "SELECT * from table1 where table1.field1
> = 9 into cursor c1"

> If I remove the val() from the thisformset.form1.field1.value in line 2
> of the original code, it gives me the following error:"Operator/operand
> mismatch"

> Thanks in advance.



Thu, 18 Jul 2002 03:00:00 GMT  
 How do I reference an integer variable in a query?
temp *has* to be of type text - remove the val() and it should work.

i.e. temp=val(thisformset.form1.field1.value) should be
temp=thisformset.form1.field1.value

John.

Quote:

> I have the below code, in which I bind the recordsource of a grid
> control to a query.
> temp=0
> temp=val(thisformset.form1.field1.value)
> thisform.grid1.RecordSource = "SELECT * from table1 where table1.field1
> = " + temp + " into cursor c1"
> thisform.grid1.refresh()

> I get the following error:"Function argument value, type, or count is
> invalid"

> It works in other instances when the variable temp is text.  It also
> works when I replace line 3 with:

> thisform.grid1.RecordSource = "SELECT * from table1 where table1.field1
> = 9 into cursor c1"

> If I remove the val() from the thisformset.form1.field1.value in line 2
> of the original code, it gives me the following error:"Operator/operand
> mismatch"

> Thanks in advance.



Thu, 18 Jul 2002 03:00:00 GMT  
 How do I reference an integer variable in a query?
Thanks for the reply John.

table1.field1 is numeric.  I should have mentioned this before.  The change
that you posted still gives operator/operand mismatch error.

Quote:

> temp *has* to be of type text - remove the val() and it should work.

> i.e. temp=val(thisformset.form1.field1.value) should be
> temp=thisformset.form1.field1.value

> John.


> > I have the below code, in which I bind the recordsource of a grid
> > control to a query.
> > temp=0
> > temp=val(thisformset.form1.field1.value)
> > thisform.grid1.RecordSource = "SELECT * from table1 where table1.field1
> > = " + temp + " into cursor c1"
> > thisform.grid1.refresh()

> > I get the following error:"Function argument value, type, or count is
> > invalid"

> > It works in other instances when the variable temp is text.  It also
> > works when I replace line 3 with:

> > thisform.grid1.RecordSource = "SELECT * from table1 where table1.field1
> > = 9 into cursor c1"

> > If I remove the val() from the thisformset.form1.field1.value in line 2
> > of the original code, it gives me the following error:"Operator/operand
> > mismatch"

> > Thanks in advance.



Thu, 18 Jul 2002 03:00:00 GMT  
 How do I reference an integer variable in a query?
I'm not sure about the "+temp+" syntax.

Let me get this right.
Table1.Field1 is Integer
Thisformset.form1.field1 is numeric.

Correct so far?

How about
temp=INT(thisformset.form1.field1.value)

thisform.grid1.RecordSource = ;
 "SELECT * from table1 where table1.field1=temp into cursor c1"

Any help?

Roger

Quote:

> Thanks for the reply John.

> table1.field1 is numeric.  I should have mentioned this before.  The change
> that you posted still gives operator/operand mismatch error.


> > temp *has* to be of type text - remove the val() and it should work.

> > i.e. temp=val(thisformset.form1.field1.value) should be
> > temp=thisformset.form1.field1.value

> > John.


> > > I have the below code, in which I bind the recordsource of a grid
> > > control to a query.
> > > temp=0
> > > temp=val(thisformset.form1.field1.value)
> > > thisform.grid1.RecordSource = "SELECT * from table1 where table1.field1
> > > = " + temp + " into cursor c1"
> > > thisform.grid1.refresh()

> > > I get the following error:"Function argument value, type, or count is
> > > invalid"

> > > It works in other instances when the variable temp is text.  It also
> > > works when I replace line 3 with:

> > > thisform.grid1.RecordSource = "SELECT * from table1 where table1.field1
> > > = 9 into cursor c1"

> > > If I remove the val() from the thisformset.form1.field1.value in line 2
> > > of the original code, it gives me the following error:"Operator/operand
> > > mismatch"

> > > Thanks in advance.



Fri, 19 Jul 2002 03:00:00 GMT  
 How do I reference an integer variable in a query?
Hi,
Try:
temp = transform(thisformset.form1.field1.value)

or if you are not using VFP 6 then:
temp = alltrim(str(thisformset.form1.field1.value))

HTH,
Larry Miller

Quote:

> Thanks for the reply John.

> table1.field1 is numeric.  I should have mentioned this before.  The
change
> that you posted still gives operator/operand mismatch error.


> > temp *has* to be of type text - remove the val() and it should work.

> > i.e. temp=val(thisformset.form1.field1.value) should be
> > temp=thisformset.form1.field1.value

> > John.




- Show quoted text -

Quote:
> > > I have the below code, in which I bind the recordsource of a grid
> > > control to a query.
> > > temp=0
> > > temp=val(thisformset.form1.field1.value)
> > > thisform.grid1.RecordSource = "SELECT * from table1 where
table1.field1
> > > = " + temp + " into cursor c1"
> > > thisform.grid1.refresh()

> > > I get the following error:"Function argument value, type, or count is
> > > invalid"

> > > It works in other instances when the variable temp is text.  It also
> > > works when I replace line 3 with:

> > > thisform.grid1.RecordSource = "SELECT * from table1 where
table1.field1
> > > = 9 into cursor c1"

> > > If I remove the val() from the thisformset.form1.field1.value in line
2
> > > of the original code, it gives me the following

error:"Operator/operand

- Show quoted text -

Quote:
> > > mismatch"

> > > Thanks in advance.



Fri, 19 Jul 2002 03:00:00 GMT  
 How do I reference an integer variable in a query?
transform works for me.  Thanks to all that replied.
Quote:

> Hi,
> Try:
> temp = transform(thisformset.form1.field1.value)

> or if you are not using VFP 6 then:
> temp = alltrim(str(thisformset.form1.field1.value))

> HTH,
> Larry Miller


> > Thanks for the reply John.

> > table1.field1 is numeric.  I should have mentioned this before.  The
> change
> > that you posted still gives operator/operand mismatch error.


> > > temp *has* to be of type text - remove the val() and it should work.

> > > i.e. temp=val(thisformset.form1.field1.value) should be
> > > temp=thisformset.form1.field1.value

> > > John.



> > > > I have the below code, in which I bind the recordsource of a grid
> > > > control to a query.
> > > > temp=0
> > > > temp=val(thisformset.form1.field1.value)
> > > > thisform.grid1.RecordSource = "SELECT * from table1 where
> table1.field1
> > > > = " + temp + " into cursor c1"
> > > > thisform.grid1.refresh()

> > > > I get the following error:"Function argument value, type, or count is
> > > > invalid"

> > > > It works in other instances when the variable temp is text.  It also
> > > > works when I replace line 3 with:

> > > > thisform.grid1.RecordSource = "SELECT * from table1 where
> table1.field1
> > > > = 9 into cursor c1"

> > > > If I remove the val() from the thisformset.form1.field1.value in line
> 2
> > > > of the original code, it gives me the following
> error:"Operator/operand
> > > > mismatch"

> > > > Thanks in advance.



Fri, 19 Jul 2002 03:00:00 GMT  
 How do I reference an integer variable in a query?
Hi,
Try:
temp = transform(thisformset.form1.field1.value)

or if you are not using VFP 6 then:
temp = alltrim(str(thisformset.form1.field1.value))

HTH,
Larry Miller

Quote:

> Thanks for the reply John.

> table1.field1 is numeric.  I should have mentioned this before.  The
change
> that you posted still gives operator/operand mismatch error.


> > temp *has* to be of type text - remove the val() and it should work.

> > i.e. temp=val(thisformset.form1.field1.value) should be
> > temp=thisformset.form1.field1.value

> > John.




- Show quoted text -

Quote:
> > > I have the below code, in which I bind the recordsource of a grid
> > > control to a query.
> > > temp=0
> > > temp=val(thisformset.form1.field1.value)
> > > thisform.grid1.RecordSource = "SELECT * from table1 where
table1.field1
> > > = " + temp + " into cursor c1"
> > > thisform.grid1.refresh()

> > > I get the following error:"Function argument value, type, or count is
> > > invalid"

> > > It works in other instances when the variable temp is text.  It also
> > > works when I replace line 3 with:

> > > thisform.grid1.RecordSource = "SELECT * from table1 where
table1.field1
> > > = 9 into cursor c1"

> > > If I remove the val() from the thisformset.form1.field1.value in line
2
> > > of the original code, it gives me the following

error:"Operator/operand

- Show quoted text -

Quote:
> > > mismatch"

> > > Thanks in advance.



Fri, 19 Jul 2002 03:00:00 GMT  
 How do I reference an integer variable in a query?
transform works for me.  Thanks to all that replied.
Quote:

> Hi,
> Try:
> temp = transform(thisformset.form1.field1.value)

> or if you are not using VFP 6 then:
> temp = alltrim(str(thisformset.form1.field1.value))

> HTH,
> Larry Miller


> > Thanks for the reply John.

> > table1.field1 is numeric.  I should have mentioned this before.  The
> change
> > that you posted still gives operator/operand mismatch error.


> > > temp *has* to be of type text - remove the val() and it should work.

> > > i.e. temp=val(thisformset.form1.field1.value) should be
> > > temp=thisformset.form1.field1.value

> > > John.



> > > > I have the below code, in which I bind the recordsource of a grid
> > > > control to a query.
> > > > temp=0
> > > > temp=val(thisformset.form1.field1.value)
> > > > thisform.grid1.RecordSource = "SELECT * from table1 where
> table1.field1
> > > > = " + temp + " into cursor c1"
> > > > thisform.grid1.refresh()

> > > > I get the following error:"Function argument value, type, or count is
> > > > invalid"

> > > > It works in other instances when the variable temp is text.  It also
> > > > works when I replace line 3 with:

> > > > thisform.grid1.RecordSource = "SELECT * from table1 where
> table1.field1
> > > > = 9 into cursor c1"

> > > > If I remove the val() from the thisformset.form1.field1.value in line
> 2
> > > > of the original code, it gives me the following
> error:"Operator/operand
> > > > mismatch"

> > > > Thanks in advance.



Fri, 19 Jul 2002 03:00:00 GMT  
 How do I reference an integer variable in a query?
My guess is that the variable has gone out of scope. Try using a custom form
property.

--

Craig Berntson
MCP, Microsoft FoxPro MVP
Salt Lake City Fox User Group
http://members.home.com/foxpro

Quote:

> I have the below code, in which I bind the recordsource of a grid
> control to a query.
> temp=0
> temp=val(thisformset.form1.field1.value)
> thisform.grid1.RecordSource = "SELECT * from table1 where table1.field1
> = " + temp + " into cursor c1"
> thisform.grid1.refresh()

> I get the following error:"Function argument value, type, or count is
> invalid"

> It works in other instances when the variable temp is text.  It also
> works when I replace line 3 with:

> thisform.grid1.RecordSource = "SELECT * from table1 where table1.field1
> = 9 into cursor c1"

> If I remove the val() from the thisformset.form1.field1.value in line 2
> of the original code, it gives me the following error:"Operator/operand
> mismatch"

> Thanks in advance.



Fri, 26 Jul 2002 03:00:00 GMT  
 
 [ 16 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Doing string compares in Foxpro Queries - help needed

2. Referencing fields as variables

3. Sending variable reference to VB COM objects from FoxPro

4. variable object referencing

5. how to use a variable as a table reference

6. Referencing values of variables

7. Reference to checkbox in a query - VFP6/SP3

8. Queries (QPRs) and Variables

9. Prompt for variable in Sql query

10. Variables in queries for VFP 5.0

11. Query Program Variables in 2.6 DOS

12. Queries (QPRs) and variables

 

 
Powered by phpBB® Forum Software