I don't get along with SQL!!!

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

Guest

Hi,
I have created a query in Access and then viewed its SQL statement that
Access generated and copied and pasted it to my Open SQL Statement. see below:

rst1Util.Open "SELECT t_GCondDetails.CommConds_Idx,
t_GCondsDB.GDB_DefaultClause FROM t_GCondsDB INNER JOIN t_GCondDetails ON
t_GCondsDB.GCondsDB_Idx = t_GCondDetails.GCondsDB_Idx WHERE
(((t_GCondDetails.CommConds_Idx)=[lkrbfrm_CommConds]![CommConds_Idx]))"

I get the following error: "Runtime error - 2147217904, No value given for
one or more required parameters"

I a suck when it comes to SQL, Can someone point out what I am doing wrong.
I am doing all the preliminary code right such as declaring ADODB.Recordset,
ADODB.Connection, rstAny1.LockType = adLockOptimistic, rstAny1.CursorLocation
= adUseServer, rstAny1.CursorType = adOpenKeyset and so forth....

All are appreciated, Thanks
Robert
 
Hey Robbie,

The parameter it is looking for is [lkrbfrm_CommConds]![CommConds_Idx]
Just by looking at it I would guess you are trying to pull this information
from a field on a form and your Open SQL doesn't know what or where this form
is.

Ken
 
Robby said:
Hi,
I have created a query in Access and then viewed its SQL statement that
Access generated and copied and pasted it to my Open SQL Statement. see below:

rst1Util.Open "SELECT t_GCondDetails.CommConds_Idx,
t_GCondsDB.GDB_DefaultClause FROM t_GCondsDB INNER JOIN t_GCondDetails ON
t_GCondsDB.GCondsDB_Idx = t_GCondDetails.GCondsDB_Idx WHERE
(((t_GCondDetails.CommConds_Idx)=[lkrbfrm_CommConds]![CommConds_Idx]))"

I get the following error: "Runtime error - 2147217904, No value given for
one or more required parameters"

I a suck when it comes to SQL, Can someone point out what I am doing wrong.
I am doing all the preliminary code right such as declaring ADODB.Recordset,
ADODB.Connection, rstAny1.LockType = adLockOptimistic, rstAny1.CursorLocation
= adUseServer, rstAny1.CursorType = adOpenKeyset and so forth....

All are appreciated, Thanks
Robert


SQL can't evaluate the reference to a control on a form that is inside the
quotes.

Try this: open the debug window (ctrl-G) and make sure you can see the
immediate window. Then paste in the following and press ENTER:

Debug.Print "SELECT t_GCondDetails.CommConds_Idx,
t_GCondsDB.GDB_DefaultClause FROM t_GCondsDB INNER JOIN t_GCondDetails ON
t_GCondsDB.GCondsDB_Idx = t_GCondDetails.GCondsDB_Idx WHERE
(((t_GCondDetails.CommConds_Idx) = [lkrbfrm_CommConds]![CommConds_Idx]))"


Now paste in this and press ENTER:

Debug.Print "SELECT t_GCondDetails.CommConds_Idx,
t_GCondsDB.GDB_DefaultClause FROM t_GCondsDB INNER JOIN t_GCondDetails ON
t_GCondsDB.GCondsDB_Idx = t_GCondDetails.GCondsDB_Idx WHERE
t_GCondDetails.CommConds_Idx = " & [Forms]![lkrbfrm_CommConds]![CommConds_Idx]

You should see a number instead of
"[Forms]![lkrbfrm_CommConds]![CommConds_Idx]"

HTH
 
Back
Top