Variable Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm using a form & VBA to get information from a query. It works but now I
want to store the information in the fields of the query to some VBA
variables. My thinking was that I have a field in the query named 'project'.
In the VBA code I dim a variable named 'projectname', in the code I said
projectname = [qryFindInfo]![project]. It does not work but am I on the
right path??

Thanks in advance
 
Dear Open:

I recommend transforming the query so it can update to cause the changes you
want to accomplish. This is easily done in most cases, and performs well.

Be sure to make a copy of the database when experimenting with any query
that can damage your data.

Tom Ellison


"open a adobe file from a command button"
 
With this limited description it is hard to say what you need to do.
Perhaps you only need to use the DLookup function.
Perhaps you need to use a recordset to hold the query result and then grab
the value you need from the recordset.

As far as I know, it is not possible to reference a query directly and get
the value of a field. Part of the difficulty in doing that would be knowing
which record to use - the first, the last, the tenth if there are ten or
more records.

DLookup does that with tables and predefined queries by grabbing the FIRST
match it finds. That doesn't mean it will scan the records in any specific
order - it could be by index, by data storage order, or other means.

If the above doesn't help you solve you problem, I suggest you post the code
you are currently using and the SQL text of your query.

"open a adobe file from a command button"
 
Back
Top