assign a field to a variable 
Author Message
 assign a field to a variable

Looking for a way to get the contents of a field form a database and
assign it to variable in VB5. I can attach a textbox by setting it
properties Datasource & datafield, but how do you get it set into a
variable?

Rex A. Walters



Sat, 26 May 2001 03:00:00 GMT  
 assign a field to a variable
You have to use DAO code, for example:
Dim rst as recordset
dim db as database

set db=opendatabase ("mydatabase.mdb")
set rst=db.openrecordset ("YourTable")
YourVariable=rst("YourNameField")
...

I suggest buy a book about VB database programming, or take a look to the VB
manuals or www.mcp.com (you can see books in VB online for free ...)

Alberto Borbolla
Microsoft MVP
Tecnologia en Sistemas
MEXICO

(replace "X" to send mail)

Quote:

>Looking for a way to get the contents of a field form a database and
>assign it to variable in VB5. I can attach a textbox by setting it
>properties Datasource & datafield, but how do you get it set into a
>variable?

>Rex A. Walters




Sun, 27 May 2001 03:00:00 GMT  
 assign a field to a variable
Coatl
    Thanks that did work, and I was searching in online books, and a couple of
books I do have but could not find how to grap just the field. But thanks again
for the help.

Rex Walters

Quote:

> You have to use DAO code, for example:
> Dim rst as recordset
> dim db as database

> set db=opendatabase ("mydatabase.mdb")
> set rst=db.openrecordset ("YourTable")
> YourVariable=rst("YourNameField")
> ...

> I suggest buy a book about VB database programming, or take a look to the VB
> manuals or www.mcp.com (you can see books in VB online for free ...)

> Alberto Borbolla
> Microsoft MVP
> Tecnologia en Sistemas
> MEXICO

> (replace "X" to send mail)


> >Looking for a way to get the contents of a field form a database and
> >assign it to variable in VB5. I can attach a textbox by setting it
> >properties Datasource & datafield, but how do you get it set into a
> >variable?

> >Rex A. Walters




Sun, 27 May 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Assign a field name to a variable

2. Assign a numeric variable to a numeric field name

3. Assign VB variable to database field name

4. Assigning field values to variables

5. Assign field to a variable

6. Assigning DB Fields to variables

7. Assigning field values to variable

8. assigning values of fields in a single row to variables

9. Assigning a Recordset field to a local variable

10. Assigning a recordset field to a variable

11. How to assign DataField property with a variable which store a field name

12. Assign variable contents to another variable

 

 
Powered by phpBB® Forum Software