Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General 2 / October 2004



Tip: Looking for answers? Try searching our database.

Can't read field values after querydef

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jt - 25 Oct 2004 18:06 GMT
Using VB6 DAO MS Access

I can't read the field values after I do a querydef. It worked prior to this
when I did just recordset.

My snippet:

       Set db = wrk.OpenDataBase(sDatabase)

       Set qdf = db.QueryDefs("Fax Numbers")

       Set rs = qdf.OpenRecordset(dbOpenDynaset)

       debug.print rs!last_name

I get an error trying to read the field value.

Any help on what I could be doing wrong?

Thanks,
jt
Harry Strybos - 25 Oct 2004 21:53 GMT
> Using VB6 DAO MS Access
>
[quoted text clipped - 18 lines]
> Thanks,
> jt

Groan...what does the error say?
jt - 26 Oct 2004 00:51 GMT
> > Using VB6 DAO MS Access
> >
[quoted text clipped - 20 lines]
> >
> Groan...what does the error say?

Error: Runtime 3265 error
Description: Item not found in this collection.

jt
Harry Strybos - 26 Oct 2004 21:23 GMT
>> > Using VB6 DAO MS Access
>> >
[quoted text clipped - 25 lines]
>
> jt

OK, that makes it a bit easier. Have a look at your saved query "Fax
Numbers". It either does not have the field "last_name" specified or aliased
to another name. Other than that, check to make sure there is not a typo in
your code.
jt - 27 Oct 2004 04:28 GMT
> > "Harry Strybos" <harry@no.spam.ffapaysmart.com.au> wrote in message

news:417d67e4$0$704$61c65585@uq-127creek-reader-02.brisbane.pipenetworks.com.au...
> >> > Using VB6 DAO MS Access
> >> >
[quoted text clipped - 30 lines]
> to another name. Other than that, check to make sure there is not a typo in
> your code.

Can you give me an example of how to read the fields when a querydef is
done?

Thanks,
Dag Sunde - 27 Oct 2004 07:29 GMT
> "Harry Strybos" <harry@no.spam.ffapaysmart.com.au> wrote in message

news:417eb262$0$708$61c65585@uq-127creek-reader-02.brisbane.pipenetworks.com.au...

> > > "Harry Strybos" <harry@no.spam.ffapaysmart.com.au> wrote in message

news:417d67e4$0$704$61c65585@uq-127creek-reader-02.brisbane.pipenetworks.com.au...
> > >> > Using VB6 DAO MS Access
> > >> >
[quoted text clipped - 36 lines]
> Can you give me an example of how to read the fields when a querydef is
> done?

Yes, as soon as you send us the *excact* names of the Queries, Column- and
tablenames as they are defined in Access.

While I'm at it: Never use special characters like "#" and its like in
table- or column names! Avoid spaces too! It's asking for trouble!

Upper and lower case a-z plus the underscore ensures you legal, portable
database-defs (as long as you avoid the db's reserved words).

Signature

Dag.

Jason Keats - 27 Oct 2004 14:29 GMT
> Can you give me an example of how to read the fields when a querydef
> is done?

This will display the fields returned by your query...

Dim i As Integer

If Not (rs Is Nothing) Then
   If rs.Fields.Count > 0 Then
       For i = 0 To rs.Fields.Count - 1
           Debug.Print i, rs.Fields(i).Name
       Next i
   End If
End If
jt - 28 Oct 2004 05:25 GMT
> > Can you give me an example of how to read the fields when a querydef
> > is done?
[quoted text clipped - 10 lines]
>     End If
> End If

How you would read the values in those fields?

Thanks,
jt
Jason Keats - 28 Oct 2004 14:15 GMT
>>> Can you give me an example of how to read the fields when a querydef
>>> is done?
[quoted text clipped - 15 lines]
> Thanks,
> jt

To display all data in a recordset, you could use something like:

Dim i As Integer

If Not (rs Is Nothing) Then
   With rs
       If .BOF And .EOF Then
           'no records returned
       Else
           '.MoveFirst
           Do Until .EOF
               For i = 0 To .Fields.Count - 1
                   Debug.Print .Fields(i).Name & " : " & .Fields(i).Value
               Next i
               Debug.Print
               .MoveNext
           Loop
       End If
   End With
End If

HTH
jt - 31 Oct 2004 18:12 GMT
> >>> Can you give me an example of how to read the fields when a querydef
> >>> is done?
[quoted text clipped - 38 lines]
>
> HTH

Thanks! Your example helped out alot on reading the field values.
jt
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.