Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.ms-access > #11931 > unrolled thread
| Started by | PW <emailaddyinsig@ifIremember.com> |
|---|---|
| First post | 2016-07-19 12:22 -0600 |
| Last post | 2016-07-21 11:26 -0600 |
| Articles | 9 — 5 participants |
Back to article view | Back to comp.databases.ms-access
"Too few parameters, expected one" PW <emailaddyinsig@ifIremember.com> - 2016-07-19 12:22 -0600
Re: "Too few parameters, expected one" Ron Paii <ron81pai@gmail.com> - 2016-07-19 12:37 -0700
Re: "Too few parameters, expected one" PW <emailaddyinsig@ifIremember.com> - 2016-07-20 10:14 -0600
Re: "Too few parameters, expected one" Patrick Finucane <patrickfinucanetx@gmail.com> - 2016-07-19 15:33 -0700
Re: "Too few parameters, expected one" PW <emailaddyinsig@ifIremember.com> - 2016-07-20 10:13 -0600
Re: "Too few parameters, expected one" Ulrich Möller <knobbi38@arcor.de> - 2016-07-20 19:28 +0200
Re: "Too few parameters, expected one" PW <emailaddyinsig@ifIremember.com> - 2016-07-20 12:51 -0600
Re: "Too few parameters, expected one" Branislav Mihaljev <banem2@gmail.com> - 2016-07-20 22:55 -0700
Re: "Too few parameters, expected one" PW <emailaddyinsig@ifIremember.com> - 2016-07-21 11:26 -0600
| From | PW <emailaddyinsig@ifIremember.com> |
|---|---|
| Date | 2016-07-19 12:22 -0600 |
| Subject | "Too few parameters, expected one" |
| Message-ID | <9jrsobddqa8qci9eu87srcfl902ilbmj1u@4ax.com> |
Hi,
I have a subform on a form. The subform is based on a query. The
query and subform run fine on their own. But when I do this, I get
that error message:
Dim db As Database
Dim rstCorrespondence As Recordset
Set db = CurrentDb()
Set rstCorrespondence = db.OpenRecordset("qrysbfCorrespondence")
The error msg is at the line above.
The query:
SELECT tblCorrespondence.*
FROM tblCorrespondence
WHERE
(((tblCorrespondence.person_id)=[Forms]![frmPeople]![txtPerson_id]));
frmPeople contains the subform on a tab.
Any ideas?
Thanks,
-paul
[toc] | [next] | [standalone]
| From | Ron Paii <ron81pai@gmail.com> |
|---|---|
| Date | 2016-07-19 12:37 -0700 |
| Message-ID | <8d5854f1-73cc-4248-9689-68ead62cdac2@googlegroups.com> |
| In reply to | #11931 |
Where is this code running? for the query to work, frmPeople needs to be open and txtPerson_id cannot be null.
[toc] | [prev] | [next] | [standalone]
| From | PW <emailaddyinsig@ifIremember.com> |
|---|---|
| Date | 2016-07-20 10:14 -0600 |
| Message-ID | <eq8vob94s02u1mn4smhsrnfnbil318b2nk@4ax.com> |
| In reply to | #11932 |
On Tue, 19 Jul 2016 12:37:48 -0700 (PDT), Ron Paii <ron81pai@gmail.com> wrote: >Where is this code running? > >for the query to work, frmPeople needs to be open and txtPerson_id cannot be null. *--- I am opening the people form with an existing record from the people table. -paulw
[toc] | [prev] | [next] | [standalone]
| From | Patrick Finucane <patrickfinucanetx@gmail.com> |
|---|---|
| Date | 2016-07-19 15:33 -0700 |
| Message-ID | <d9c0d0ea-a2c3-41f0-bcec-bfe7cc350e1c@googlegroups.com> |
| In reply to | #11931 |
On Tuesday, July 19, 2016 at 2:22:23 PM UTC-4, PW wrote:
> Hi,
>
> I have a subform on a form. The subform is based on a query. The
> query and subform run fine on their own. But when I do this, I get
> that error message:
>
> Dim db As Database
> Dim rstCorrespondence As Recordset
>
> Set db = CurrentDb()
>
> Set rstCorrespondence = db.OpenRecordset("qrysbfCorrespondence")
>
> The error msg is at the line above.
>
> The query:
>
> SELECT tblCorrespondence.*
> FROM tblCorrespondence
> WHERE
> (((tblCorrespondence.person_id)=[Forms]![frmPeople]![txtPerson_id]));
>
>
> frmPeople contains the subform on a tab.
>
> Any ideas?
>
> Thanks,
>
> -paul
I'm a tad confused...is frmPeople the main form or is it the subform. I don't see how if it is the subform it can run fine with your query.
>
[toc] | [prev] | [next] | [standalone]
| From | PW <emailaddyinsig@ifIremember.com> |
|---|---|
| Date | 2016-07-20 10:13 -0600 |
| Message-ID | <7n8vobhektmsm7e1epjsj2gbv8k6apqkqh@4ax.com> |
| In reply to | #11933 |
On Tue, 19 Jul 2016 15:33:01 -0700 (PDT), Patrick Finucane
<patrickfinucanetx@gmail.com> wrote:
>On Tuesday, July 19, 2016 at 2:22:23 PM UTC-4, PW wrote:
>> Hi,
>>
>> I have a subform on a form. The subform is based on a query. The
>> query and subform run fine on their own. But when I do this, I get
>> that error message:
>>
>> Dim db As Database
>> Dim rstCorrespondence As Recordset
>>
>> Set db = CurrentDb()
>>
>> Set rstCorrespondence = db.OpenRecordset("qrysbfCorrespondence")
>>
>> The error msg is at the line above.
>>
>> The query:
>>
>> SELECT tblCorrespondence.*
>> FROM tblCorrespondence
>> WHERE
>> (((tblCorrespondence.person_id)=[Forms]![frmPeople]![txtPerson_id]));
>>
>>
>> frmPeople contains the subform on a tab.
>>
>> Any ideas?
>>
>> Thanks,
>>
>> -paul
>
>I'm a tad confused...is frmPeople the main form or is it the subform. I don't see how if it is the subform it can run fine with your query.
>>
*----
The subform is on a tab on the people form and is open and is only
accessed from the people form..
-paulw
[toc] | [prev] | [next] | [standalone]
| From | Ulrich Möller <knobbi38@arcor.de> |
|---|---|
| Date | 2016-07-20 19:28 +0200 |
| Message-ID | <nmoc7h$ro1$1@dont-email.me> |
| In reply to | #11935 |
Am 20.07.2016 um 18:13 schrieb PW:
> On Tue, 19 Jul 2016 15:33:01 -0700 (PDT), Patrick Finucane
> <patrickfinucanetx@gmail.com> wrote:
>
>> On Tuesday, July 19, 2016 at 2:22:23 PM UTC-4, PW wrote:
>>> Hi,
>>>
>>> I have a subform on a form. The subform is based on a query. The
>>> query and subform run fine on their own. But when I do this, I get
>>> that error message:
>>>
>>> Dim db As Database
>>> Dim rstCorrespondence As Recordset
>>>
>>> Set db = CurrentDb()
>>>
>>> Set rstCorrespondence = db.OpenRecordset("qrysbfCorrespondence")
>>>
>>> The error msg is at the line above.
>>>
>>> The query:
>>>
>>> SELECT tblCorrespondence.*
>>> FROM tblCorrespondence
>>> WHERE
>>> (((tblCorrespondence.person_id)=[Forms]![frmPeople]![txtPerson_id]));
>>>
>>>
>>> frmPeople contains the subform on a tab.
>>>
>>> Any ideas?
>>>
>>> Thanks,
>>>
>>> -paul
>> I'm a tad confused...is frmPeople the main form or is it the subform. I don't see how if it is the subform it can run fine with your query.
> *----
>
> The subform is on a tab on the people form and is open and is only
> accessed from the people form..
>
> -paulw
Hi,
if "txtPerson_id" is a control on a subform, you have to change the refer.
See http://access.mvps.org/access/forms/frm0031.htm for the correct
notation.
Ulrich
[toc] | [prev] | [next] | [standalone]
| From | PW <emailaddyinsig@ifIremember.com> |
|---|---|
| Date | 2016-07-20 12:51 -0600 |
| Message-ID | <bvhvob1dfphp3r6gc26n7pc1om22qn2ptt@4ax.com> |
| In reply to | #11937 |
On Wed, 20 Jul 2016 19:28:31 +0200, Ulrich Möller <knobbi38@arcor.de>
wrote:
>Am 20.07.2016 um 18:13 schrieb PW:
>> On Tue, 19 Jul 2016 15:33:01 -0700 (PDT), Patrick Finucane
>> <patrickfinucanetx@gmail.com> wrote:
>>
>>> On Tuesday, July 19, 2016 at 2:22:23 PM UTC-4, PW wrote:
>>>> Hi,
>>>>
>>>> I have a subform on a form. The subform is based on a query. The
>>>> query and subform run fine on their own. But when I do this, I get
>>>> that error message:
>>>>
>>>> Dim db As Database
>>>> Dim rstCorrespondence As Recordset
>>>>
>>>> Set db = CurrentDb()
>>>>
>>>> Set rstCorrespondence = db.OpenRecordset("qrysbfCorrespondence")
>>>>
>>>> The error msg is at the line above.
>>>>
>>>> The query:
>>>>
>>>> SELECT tblCorrespondence.*
>>>> FROM tblCorrespondence
>>>> WHERE
>>>> (((tblCorrespondence.person_id)=[Forms]![frmPeople]![txtPerson_id]));
>>>>
>>>>
>>>> frmPeople contains the subform on a tab.
>>>>
>>>> Any ideas?
>>>>
>>>> Thanks,
>>>>
>>>> -paul
>>> I'm a tad confused...is frmPeople the main form or is it the subform. I don't see how if it is the subform it can run fine with your query.
>> *----
>>
>> The subform is on a tab on the people form and is open and is only
>> accessed from the people form..
>>
>> -paulw
>Hi,
>
>if "txtPerson_id" is a control on a subform, you have to change the refer.
>
>See http://access.mvps.org/access/forms/frm0031.htm for the correct
>notation.
>
>Ulrich
*---
I took the filter out of the query and put a filter in code:
Set rstCorrespondence = db.OpenRecordset("Select * From
qrysbfCorrespondence Where person_id = " &
Forms!frmPeople!txtperson_id)
It worked!
Thanks everyone
-paulw
[toc] | [prev] | [next] | [standalone]
| From | Branislav Mihaljev <banem2@gmail.com> |
|---|---|
| Date | 2016-07-20 22:55 -0700 |
| Message-ID | <c81be14e-858a-469d-933a-44b4fc02fae4@googlegroups.com> |
| In reply to | #11931 |
This should work:
Dim db As Database
Dim rstCorrespondence As Recordset
Dim qdf As QueryDef
Set db = CurrentDb()
Set qdf = db.QueryDefs("qrysbfCorrespondence")
qdf.Parameters("tblCorrespondence.person_id") = [Forms]![frmPeople]![txtPerson_id]
'or
'qdf.Parameters(0) = [Forms]![frmPeople]![txtPerson_id]
Set rstCorrespondence = qdf.OpenRecordset()
You have a query with the parameter which you are not defining with the open recordset method.
Do not forget to close everything:
rstCorrespondence.Close
qdf.Close
db.Close
rst = Nothing
qdf = Nothing
db = Nothing
Regards,
Branislav Mihaljev
[toc] | [prev] | [next] | [standalone]
| From | PW <emailaddyinsig@ifIremember.com> |
|---|---|
| Date | 2016-07-21 11:26 -0600 |
| Message-ID | <j812pbpip574dqj6oeo2bolotsrjkkrh3o@4ax.com> |
| In reply to | #11939 |
On Wed, 20 Jul 2016 22:55:58 -0700 (PDT), Branislav Mihaljev
<banem2@gmail.com> wrote:
>This should work:
>
>Dim db As Database
>Dim rstCorrespondence As Recordset
>Dim qdf As QueryDef
>
>Set db = CurrentDb()
>Set qdf = db.QueryDefs("qrysbfCorrespondence")
>
>qdf.Parameters("tblCorrespondence.person_id") = [Forms]![frmPeople]![txtPerson_id]
>'or
>'qdf.Parameters(0) = [Forms]![frmPeople]![txtPerson_id]
>
>Set rstCorrespondence = qdf.OpenRecordset()
>
>
>You have a query with the parameter which you are not defining with the open recordset method.
>
>Do not forget to close everything:
>
>rstCorrespondence.Close
>qdf.Close
>db.Close
>rst = Nothing
>qdf = Nothing
>db = Nothing
>
>Regards,
>Branislav Mihaljev
*---
Good stuff. I have to admit that I have never used Query Definitions.
I need to start! Totally makes sense.
Thank you!
-paulw
[toc] | [prev] | [standalone]
Back to top | Article view | comp.databases.ms-access
csiph-web