PC Review


Reply
Thread Tools Rate Thread

How do I link a lookup query to an ADO table?

 
 
=?Utf-8?B?QWw=?=
Guest
Posts: n/a
 
      29th Jun 2005
I have a process which will read through a database, assign report variables
and print a report. Below is a sample.

01 Sub Print_Mailing()
02 Set rstl = New ADODB.Recordset
03 With rstl
04 .ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
05 "Data Source=C:\mailing\mailing.mdb;"
06 .Open "MailingSample", , , , adCmdTable
07 End With
08
09 'LOOP THROUGH TABLE
10 Do Until rstl.EOF
11 If IsNull(rstl.Fields(11)) = True Then 'set Name
12 strName = Trim(rstl.Fields(11))
13 'OPEN SETTINGS QUERY AND TRANSFER VALUES TO REPORTS TABLE
14 DoCmd.SetWarnings False
15 DoCmd.OpenQuery "qmakReportMailing" '<==This is what I am having
a problem with.
16 rstl.MoveNext
17 Loop
18 rstl.Close
19 Set rstl = Nothing
20 End Sub

I would like Line 15 to run a qmake query based upon the value of the ID of
the current record in the ADO table.

Below is a listing of this query as I used it to tie to an Input Form:

qmakReportMailing: (when connected to Input Form--this works)
SELECT tblInput.insInputID
FROM tblInput
WHERE (((tblInput.insInputID)=[Forms]![frmInput]![insInputID])

How do I or what is the syntax to point directly to the database current
record without using a form?
The database id field is rstl.Fields(1) named "ID" in the database definition.

qmakReportMailing: (when connected to Mailingsample database)
SELECT MailingSample.ID
FROM MailingSample
WHERE (((MailingSample.ID)=?????)

Thanks for your help!!
 
Reply With Quote
 
 
 
 
Alex Dybenko
Guest
Posts: n/a
 
      29th Jun 2005
Hi,
i think the simple solution is to have a hidden form loaded,
then you can use a textbox on it to filter your query, and set this textbox
to id of current record in your code:
Foms("MyForm").txtID=rstl("ID")

--
Alex Dybenko (MVP)
http://Alex.Dybenko.com
http://www.PointLtd.com


"Al" <(E-Mail Removed)> wrote in message
news:151884C9-2835-4402-ADEA-(E-Mail Removed)...
>I have a process which will read through a database, assign report
>variables
> and print a report. Below is a sample.
>
> 01 Sub Print_Mailing()
> 02 Set rstl = New ADODB.Recordset
> 03 With rstl
> 04 .ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
> 05 "Data Source=C:\mailing\mailing.mdb;"
> 06 .Open "MailingSample", , , , adCmdTable
> 07 End With
> 08
> 09 'LOOP THROUGH TABLE
> 10 Do Until rstl.EOF
> 11 If IsNull(rstl.Fields(11)) = True Then 'set Name
> 12 strName = Trim(rstl.Fields(11))
> 13 'OPEN SETTINGS QUERY AND TRANSFER VALUES TO REPORTS TABLE
> 14 DoCmd.SetWarnings False
> 15 DoCmd.OpenQuery "qmakReportMailing" '<==This is what I am
> having
> a problem with.
> 16 rstl.MoveNext
> 17 Loop
> 18 rstl.Close
> 19 Set rstl = Nothing
> 20 End Sub
>
> I would like Line 15 to run a qmake query based upon the value of the ID
> of
> the current record in the ADO table.
>
> Below is a listing of this query as I used it to tie to an Input Form:
>
> qmakReportMailing: (when connected to Input Form--this works)
> SELECT tblInput.insInputID
> FROM tblInput
> WHERE (((tblInput.insInputID)=[Forms]![frmInput]![insInputID])
>
> How do I or what is the syntax to point directly to the database current
> record without using a form?
> The database id field is rstl.Fields(1) named "ID" in the database
> definition.
>
> qmakReportMailing: (when connected to Mailingsample database)
> SELECT MailingSample.ID
> FROM MailingSample
> WHERE (((MailingSample.ID)=?????)
>
> Thanks for your help!!



 
Reply With Quote
 
=?Utf-8?B?QWw=?=
Guest
Posts: n/a
 
      29th Jun 2005
Thanks Alex,

I did a little twist to your recommendation. I thought I would respond to
your answer so others could find the solution.

I was not able to directly set the value of the ID field in the text box on
the hidden input form. What I did was set up a record lookup instead. It
looks like this:

DoCmd.GoToRecord acDataForm, "frmMailing", acGoTo, rstl("ID")

Thanks again for your assistance!!



"Alex Dybenko" wrote:

> Hi,
> i think the simple solution is to have a hidden form loaded,
> then you can use a textbox on it to filter your query, and set this textbox
> to id of current record in your code:
> Foms("MyForm").txtID=rstl("ID")
>
> --
> Alex Dybenko (MVP)
> http://Alex.Dybenko.com
> http://www.PointLtd.com
>
>
> "Al" <(E-Mail Removed)> wrote in message
> news:151884C9-2835-4402-ADEA-(E-Mail Removed)...
> >I have a process which will read through a database, assign report
> >variables
> > and print a report. Below is a sample.
> >
> > 01 Sub Print_Mailing()
> > 02 Set rstl = New ADODB.Recordset
> > 03 With rstl
> > 04 .ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
> > 05 "Data Source=C:\mailing\mailing.mdb;"
> > 06 .Open "MailingSample", , , , adCmdTable
> > 07 End With
> > 08
> > 09 'LOOP THROUGH TABLE
> > 10 Do Until rstl.EOF
> > 11 If IsNull(rstl.Fields(11)) = True Then 'set Name
> > 12 strName = Trim(rstl.Fields(11))
> > 13 'OPEN SETTINGS QUERY AND TRANSFER VALUES TO REPORTS TABLE
> > 14 DoCmd.SetWarnings False
> > 15 DoCmd.OpenQuery "qmakReportMailing" '<==This is what I am
> > having
> > a problem with.
> > 16 rstl.MoveNext
> > 17 Loop
> > 18 rstl.Close
> > 19 Set rstl = Nothing
> > 20 End Sub
> >
> > I would like Line 15 to run a qmake query based upon the value of the ID
> > of
> > the current record in the ADO table.
> >
> > Below is a listing of this query as I used it to tie to an Input Form:
> >
> > qmakReportMailing: (when connected to Input Form--this works)
> > SELECT tblInput.insInputID
> > FROM tblInput
> > WHERE (((tblInput.insInputID)=[Forms]![frmInput]![insInputID])
> >
> > How do I or what is the syntax to point directly to the database current
> > record without using a form?
> > The database id field is rstl.Fields(1) named "ID" in the database
> > definition.
> >
> > qmakReportMailing: (when connected to Mailingsample database)
> > SELECT MailingSample.ID
> > FROM MailingSample
> > WHERE (((MailingSample.ID)=?????)
> >
> > Thanks for your help!!

>
>
>

 
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
Using a query as a lookup table Evi Microsoft Access Database Table Design 0 21st Oct 2008 12:15 AM
Table/Query Lookup =?Utf-8?B?Ri4gTS4gVG9t?= Microsoft Access Getting Started 11 9th Feb 2006 06:05 AM
A query based on a query and a Link table - Problems connecting =?Utf-8?B?ZXNwYXJ6YW9uZQ==?= Microsoft Access Queries 3 16th Jun 2005 11:27 AM
Query on table with a lookup Jen Microsoft Access Queries 1 27th Apr 2004 06:46 PM
Query or lookup table? Amit Microsoft Access Forms 0 27th Aug 2003 07:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:31 AM.