PC Review


Reply
Thread Tools Rate Thread

Recordset problem

 
 
Tim
Guest
Posts: n/a
 
      2nd Aug 2003
Hi everyone,

I created a recordset from query. But, it didn't work.
Could anyone can help me?


Dim db As Database
Dim rst As Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("select ID from qryemp;")

Debug.Print rst.Fields("ID").Value


Thanks in advance.

Tim.
 
Reply With Quote
 
 
 
 
Ken Snell
Guest
Posts: n/a
 
      2nd Aug 2003
What do you mean by "it didn't work"?

--
Ken Snell
<MS ACCESS MVP>

"Tim" <(E-Mail Removed)> wrote in message
news:060601c35895$f966c860$(E-Mail Removed)...
> Hi everyone,
>
> I created a recordset from query. But, it didn't work.
> Could anyone can help me?
>
>
> Dim db As Database
> Dim rst As Recordset
>
> Set db = CurrentDb
> Set rst = db.OpenRecordset("select ID from qryemp;")
>
> Debug.Print rst.Fields("ID").Value
>
>
> Thanks in advance.
>
> Tim.



 
Reply With Quote
 
Ken Snell
Guest
Posts: n/a
 
      2nd Aug 2003
< g >

--
Ken Snell
<MS ACCESS MVP>

"TC" <(E-Mail Removed)> wrote in message news:1059799979.239599@teuthos...
> Give up, Ken!!
>
> TC
>
>
> "Tim" <(E-Mail Removed)> wrote in message
> news:068a01c358a6$72966460$(E-Mail Removed)...
> > Ken,
> >
> > Sorry, I missed some code from the line.
> >
> > Set rst = db.OpenRecordset("select ID from qryemp;")
> >
> > The correct one is the following:
> >
> > Set rst = db.OpenRecordset("select ID from qryemp-ID;")
> >
> > When I ran the sub, I got error message. Could you tell
> > me how to fix it?
> >
> > Thanks.
> >
> > Tim.
> >
> > >-----Original Message-----
> > >What do you mean by "it didn't work"?
> > >
> > >--
> > > Ken Snell
> > ><MS ACCESS MVP>
> > >
> > >"Tim" <(E-Mail Removed)> wrote in message
> > >news:060601c35895$f966c860$(E-Mail Removed)...
> > >> Hi everyone,
> > >>
> > >> I created a recordset from query. But, it didn't work.
> > >> Could anyone can help me?
> > >>
> > >>
> > >> Dim db As Database
> > >> Dim rst As Recordset
> > >>
> > >> Set db = CurrentDb
> > >> Set rst = db.OpenRecordset("select ID from qryemp;")
> > >>
> > >> Debug.Print rst.Fields("ID").Value
> > >>
> > >>
> > >> Thanks in advance.
> > >>
> > >> Tim.
> > >
> > >
> > >.
> > >

>
>



 
Reply With Quote
 
Tim
Guest
Posts: n/a
 
      3rd Aug 2003
Ken,

The error message is:

Run-time error 3131:
Syntax error in From clause.

Thanks.

Tim.
>-----Original Message-----
>What is the error message?
>
>--
> Ken Snell
><MS ACCESS MVP>
>
>"Tim" <(E-Mail Removed)> wrote in message
>news:068a01c358a6$72966460$(E-Mail Removed)...
>> Ken,
>>
>> Sorry, I missed some code from the line.
>>
>> Set rst = db.OpenRecordset("select ID from qryemp;")
>>
>> The correct one is the following:
>>
>> Set rst = db.OpenRecordset("select ID from qryemp-ID;")
>>
>> When I ran the sub, I got error message. Could you tell
>> me how to fix it?
>>
>> Thanks.
>>
>> Tim.
>>
>> >-----Original Message-----
>> >What do you mean by "it didn't work"?
>> >
>> >--
>> > Ken Snell
>> ><MS ACCESS MVP>
>> >
>> >"Tim" <(E-Mail Removed)> wrote in message
>> >news:060601c35895$f966c860$(E-Mail Removed)...
>> >> Hi everyone,
>> >>
>> >> I created a recordset from query. But, it didn't

work.
>> >> Could anyone can help me?
>> >>
>> >>
>> >> Dim db As Database
>> >> Dim rst As Recordset
>> >>
>> >> Set db = CurrentDb
>> >> Set rst = db.OpenRecordset("select ID from qryemp;")
>> >>
>> >> Debug.Print rst.Fields("ID").Value
>> >>
>> >>
>> >> Thanks in advance.
>> >>
>> >> Tim.
>> >
>> >
>> >.
>> >

>
>
>.
>

 
Reply With Quote
 
Ken Snell
Guest
Posts: n/a
 
      3rd Aug 2003
You need to put square brackets around the query name because you have a
hyphen as part of the name:

Set rst = db.OpenRecordset("select ID from [qryemp-ID];")
--
Ken Snell
<MS ACCESS MVP>

"Tim" <(E-Mail Removed)> wrote in message
news:030101c35966$961bb3c0$(E-Mail Removed)...
> Ken,
>
> The error message is:
>
> Run-time error 3131:
> Syntax error in From clause.
>
> Thanks.
>
> Tim.
> >-----Original Message-----
> >What is the error message?
> >
> >--
> > Ken Snell
> ><MS ACCESS MVP>
> >
> >"Tim" <(E-Mail Removed)> wrote in message
> >news:068a01c358a6$72966460$(E-Mail Removed)...
> >> Ken,
> >>
> >> Sorry, I missed some code from the line.
> >>
> >> Set rst = db.OpenRecordset("select ID from qryemp;")
> >>
> >> The correct one is the following:
> >>
> >> Set rst = db.OpenRecordset("select ID from qryemp-ID;")
> >>
> >> When I ran the sub, I got error message. Could you tell
> >> me how to fix it?
> >>
> >> Thanks.
> >>
> >> Tim.
> >>
> >> >-----Original Message-----
> >> >What do you mean by "it didn't work"?
> >> >
> >> >--
> >> > Ken Snell
> >> ><MS ACCESS MVP>
> >> >
> >> >"Tim" <(E-Mail Removed)> wrote in message
> >> >news:060601c35895$f966c860$(E-Mail Removed)...
> >> >> Hi everyone,
> >> >>
> >> >> I created a recordset from query. But, it didn't

> work.
> >> >> Could anyone can help me?
> >> >>
> >> >>
> >> >> Dim db As Database
> >> >> Dim rst As Recordset
> >> >>
> >> >> Set db = CurrentDb
> >> >> Set rst = db.OpenRecordset("select ID from qryemp;")
> >> >>
> >> >> Debug.Print rst.Fields("ID").Value
> >> >>
> >> >>
> >> >> Thanks in advance.
> >> >>
> >> >> Tim.
> >> >
> >> >
> >> >.
> >> >

> >
> >
> >.
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with recordset ma Microsoft Access VBA Modules 2 16th May 2005 11:31 PM
problem with recordset ma Microsoft Access 2 16th May 2005 11:31 PM
Recordset problem =?Utf-8?B?YnV6eg==?= Microsoft Access VBA Modules 7 9th Dec 2004 12:49 AM
Problem with Set combobox.recordset = <adodb.recordset> Gijs Beukenoot Microsoft Access Form Coding 0 10th Nov 2004 07:22 PM
Re: !Recordset from a parameterized query, as the form's recordset. Problem on sorting... Savvoulidis Iordanis Microsoft Access Forms 0 24th Jun 2004 09:52 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:59 AM.