Need help with accessing recordset data 
Author Message
 Need help with accessing recordset data

I'm using access2000. On a form I have a command button to run the
following code. When the code runs I get the error Method or Data member
not found on the code in blue. Can anyone tell me what I'm doing wrong?

Private Sub cmdUpdate_Click()
On Error GoTo Err_cmdUpdate_Click

    Dim stDocName As String
    Dim dbCurrent As Database
    Dim qdf As QueryDef
    Dim rst As Recordset
    Dim str As String
    Dim strInsert As String
    Dim strValues As String

    Set qdf = dbCurrent.QueryDefs("qryLookupIDs")
    Set rst = qdf.OpenRecordset(dbOpenDynaset)

    strInsert = "Insert Into [tblLinked_Categories] "
    strValues = "Values (" & rst.Category_ID & ", " &
rst.Subcategory1_ID & ", " & rst.Subcategory2_ID
    strValues = strValues & ");"
    str = strInsert & strValues
    Debug.Print str
    'dbCurrent.Execute str, dbFailOnError

    Set dbCurrent = Nothing

Exit_cmdUpdate_Click:
    Exit Sub

Err_cmdUpdate_Click:
    MsgBox Err.Description
    Resume Exit_cmdUpdate_Click

End Sub



Sat, 07 May 2005 22:49:57 GMT  
 Need help with accessing recordset data
Use the bang (!) operator instead of the dot (.) operator.
    rst!Category_ID
--
Hoping that this is helpful...
       Ken Snell
<MS ACCESS MVP>


Quote:
> I'm using access2000. On a form I have a command button to run the
> following code. When the code runs I get the error Method or Data member
> not found on the code in blue. Can anyone tell me what I'm doing wrong?

> Private Sub cmdUpdate_Click()
> On Error GoTo Err_cmdUpdate_Click

>     Dim stDocName As String
>     Dim dbCurrent As Database
>     Dim qdf As QueryDef
>     Dim rst As Recordset
>     Dim str As String
>     Dim strInsert As String
>     Dim strValues As String

>     Set qdf = dbCurrent.QueryDefs("qryLookupIDs")
>     Set rst = qdf.OpenRecordset(dbOpenDynaset)

>     strInsert = "Insert Into [tblLinked_Categories] "
>     strValues = "Values (" & rst.Category_ID & ", " &
> rst.Subcategory1_ID & ", " & rst.Subcategory2_ID
>     strValues = strValues & ");"
>     str = strInsert & strValues
>     Debug.Print str
>     'dbCurrent.Execute str, dbFailOnError

>     Set dbCurrent = Nothing

> Exit_cmdUpdate_Click:
>     Exit Sub

> Err_cmdUpdate_Click:
>     MsgBox Err.Description
>     Resume Exit_cmdUpdate_Click

> End Sub



Sat, 07 May 2005 22:54:14 GMT  
 Need help with accessing recordset data

Thanks but that didn't help. I double checked my query btw to make sure
the field was spelled correctly. Here's the sqlview source code of the query

SELECT tblCategories.Category_ID, tblSubcategories1.SubCategory1_ID,
tblSubcategories2.Subcategory2_ID
FROM tblSubcategories1, tblCategories, tblSubcategories2
WHERE (((tblCategories.Category_Type)=[Forms]![frmAdd Categories and
Subcategories]![cboCategory]) AND
((tblSubcategories1.SubCategory1_Type)=[Forms]![frmAdd Categories and
Subcategories]![cboSubCategory1]) AND
((tblSubcategories2.Subcategory2_Type)=[Forms]![frmAdd Categories and
Subcategories]![cboSubcategory2]));

Any other ideas?

Quote:

>Use the bang (!) operator instead of the dot (.) operator.
>    rst!Category_ID
>--
>Hoping that this is helpful...
>       Ken Snell
><MS ACCESS MVP>



>>I'm using access2000. On a form I have a command button to run the
>>following code. When the code runs I get the error Method or Data member
>>not found on the code in blue. Can anyone tell me what I'm doing wrong?

>>Private Sub cmdUpdate_Click()
>>On Error GoTo Err_cmdUpdate_Click

>>    Dim stDocName As String
>>    Dim dbCurrent As Database
>>    Dim qdf As QueryDef
>>    Dim rst As Recordset
>>    Dim str As String
>>    Dim strInsert As String
>>    Dim strValues As String

>>    Set qdf = dbCurrent.QueryDefs("qryLookupIDs")
>>    Set rst = qdf.OpenRecordset(dbOpenDynaset)

>>    strInsert = "Insert Into [tblLinked_Categories] "
>>    strValues = "Values (" & rst.Category_ID & ", " &
>>rst.Subcategory1_ID & ", " & rst.Subcategory2_ID
>>    strValues = strValues & ");"
>>    str = strInsert & strValues
>>    Debug.Print str
>>    'dbCurrent.Execute str, dbFailOnError

>>    Set dbCurrent = Nothing

>>Exit_cmdUpdate_Click:
>>    Exit Sub

>>Err_cmdUpdate_Click:
>>    MsgBox Err.Description
>>    Resume Exit_cmdUpdate_Click

>>End Sub



Sat, 07 May 2005 23:20:06 GMT  
 Need help with accessing recordset data
try adding the line:

set dbcurrent = currentdb

your first set statement refers to dbcurrent, but you
haven't set that variable yet!

HTH
-hai

Quote:
>-----Original Message-----
>I'm using access2000. On a form I have a command button
to run the
>following code. When the code runs I get the error Method
or Data member
>not found on the code in blue. Can anyone tell me what
I'm doing wrong?

>Private Sub cmdUpdate_Click()
>On Error GoTo Err_cmdUpdate_Click

>    Dim stDocName As String
>    Dim dbCurrent As Database
>    Dim qdf As QueryDef
>    Dim rst As Recordset
>    Dim str As String
>    Dim strInsert As String
>    Dim strValues As String

>    Set qdf = dbCurrent.QueryDefs("qryLookupIDs")
>    Set rst = qdf.OpenRecordset(dbOpenDynaset)

>    strInsert = "Insert Into [tblLinked_Categories] "
>    strValues = "Values (" & rst.Category_ID & ", " &
>rst.Subcategory1_ID & ", " & rst.Subcategory2_ID
>    strValues = strValues & ");"
>    str = strInsert & strValues
>    Debug.Print str
>    'dbCurrent.Execute str, dbFailOnError

>    Set dbCurrent = Nothing

>Exit_cmdUpdate_Click:
>    Exit Sub

>Err_cmdUpdate_Click:
>    MsgBox Err.Description
>    Resume Exit_cmdUpdate_Click

>End Sub



Sat, 07 May 2005 23:43:01 GMT  
 Need help with accessing recordset data
As hai suggests, include in your code the step to set the object variable
dbcurrent to be your current database.
--
Hoping that this is helpful...
       Ken Snell
<MS ACCESS MVP>


Quote:
> Thanks but that didn't help. I double checked my query btw to make sure
> the field was spelled correctly. Here's the sqlview source code of the
query

> SELECT tblCategories.Category_ID, tblSubcategories1.SubCategory1_ID,
> tblSubcategories2.Subcategory2_ID
> FROM tblSubcategories1, tblCategories, tblSubcategories2
> WHERE (((tblCategories.Category_Type)=[Forms]![frmAdd Categories and
> Subcategories]![cboCategory]) AND
> ((tblSubcategories1.SubCategory1_Type)=[Forms]![frmAdd Categories and
> Subcategories]![cboSubCategory1]) AND
> ((tblSubcategories2.Subcategory2_Type)=[Forms]![frmAdd Categories and
> Subcategories]![cboSubcategory2]));

> Any other ideas?


> >Use the bang (!) operator instead of the dot (.) operator.
> >    rst!Category_ID
> >--
> >Hoping that this is helpful...
> >       Ken Snell
> ><MS ACCESS MVP>



> >>I'm using access2000. On a form I have a command button to run the
> >>following code. When the code runs I get the error Method or Data member
> >>not found on the code in blue. Can anyone tell me what I'm doing wrong?

> >>Private Sub cmdUpdate_Click()
> >>On Error GoTo Err_cmdUpdate_Click

> >>    Dim stDocName As String
> >>    Dim dbCurrent As Database
> >>    Dim qdf As QueryDef
> >>    Dim rst As Recordset
> >>    Dim str As String
> >>    Dim strInsert As String
> >>    Dim strValues As String

> >>    Set qdf = dbCurrent.QueryDefs("qryLookupIDs")
> >>    Set rst = qdf.OpenRecordset(dbOpenDynaset)

> >>    strInsert = "Insert Into [tblLinked_Categories] "
> >>    strValues = "Values (" & rst.Category_ID & ", " &
> >>rst.Subcategory1_ID & ", " & rst.Subcategory2_ID
> >>    strValues = strValues & ");"
> >>    str = strInsert & strValues
> >>    Debug.Print str
> >>    'dbCurrent.Execute str, dbFailOnError

> >>    Set dbCurrent = Nothing

> >>Exit_cmdUpdate_Click:
> >>    Exit Sub

> >>Err_cmdUpdate_Click:
> >>    MsgBox Err.Description
> >>    Resume Exit_cmdUpdate_Click

> >>End Sub



Sun, 08 May 2005 00:29:04 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Help needed with VBA to take data from a recordset to fill a listbox

2. Help needed displaying data from recordset

3. Problems assigning a DAO-recordset to a data control - Need help

4. help! accessing Recordset data

5. Help needed with connection for recordset in MS Access

6. Need help with FIND and SEEK Recordset from Access Database

7. Help with Access ADO recordset needed

8. Using RecordSets within Access 2000 Data Access Pages

9. Need HELP Importing Access List Box data to Word document

10. need help with Datagrid / ADO Data Control / Access Database / delete method

11. Help needed to send data to Access DB

12. Beginner Needs Help with Data Access

 

 
Powered by phpBB® Forum Software