PC Review


Reply
Thread Tools Rate Thread

ADODB Recordset runtime error '3021'

 
 
Brian Hoffman
Guest
Posts: n/a
 
      15th Jun 2009
If Len(cboType) > 0 Then

Dim cnn1 As ADODB.Connection
Set cnn1 = CurrentProject.Connection
Dim rst1 As New ADODB.Recordset
rst1.ActiveConnection = cnn1

Dim mySQL As String
mySQL = "SELECT [PKResType#] FROM tblResTypes"
mySQL = mySQL + " WHERE (([Resource]='Me.[cboRes]')"
mySQL = mySQL + " AND ([Type]='Me.[cboType]'))"

rst1.Open mySQL
rst1.MoveFirst

I am fairly new to programming, so I have taken alot of my work directly
from textbooks. Can anyone explain why BOF and EOF are true here?
 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      15th Jun 2009
Your references to cboRes and cboType must be outside of the quotes.

mySQL = mySQL & " WHERE (([Resource]='" & Me.[cboRes] & "')"
mySQL = mySQL & " AND ([Type]=" & Me.[cboType] & "))"

Look at the difference in what I put there: I've assumed that Resource is a
text field, while Type is a numeric field. Exagerated for clarity, that's

mySQL = mySQL & " WHERE (([Resource]=' " & Me.[cboRes] & " ' )"
mySQL = mySQL & " AND ([Type]=" & Me.[cboType] & "))"



--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Brian Hoffman" <(E-Mail Removed)> wrote in message
news:7198D4CB-44BA-4977-87CB-(E-Mail Removed)...
> If Len(cboType) > 0 Then
>
> Dim cnn1 As ADODB.Connection
> Set cnn1 = CurrentProject.Connection
> Dim rst1 As New ADODB.Recordset
> rst1.ActiveConnection = cnn1
>
> Dim mySQL As String
> mySQL = "SELECT [PKResType#] FROM tblResTypes"
> mySQL = mySQL + " WHERE (([Resource]='Me.[cboRes]')"
> mySQL = mySQL + " AND ([Type]='Me.[cboType]'))"
>
> rst1.Open mySQL
> rst1.MoveFirst
>
> I am fairly new to programming, so I have taken alot of my work directly
> from textbooks. Can anyone explain why BOF and EOF are true here?



 
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
ADODB Recordset runtime error '3021' Brian Hoffman Microsoft Access 2 24th Jun 2009 01:36 AM
ADODB 3021 Error but there IS a record =?Utf-8?B?RG9t?= Microsoft Access VBA Modules 1 16th Mar 2005 09:15 PM
Bug: Empty "If Me.Recordset Is Nothing Then" clause causes runtime error 3021 (Access 2003) Boris Microsoft Access Forms 37 25th Aug 2004 07:32 PM
Bug: Empty "If Me.Recordset Is Nothing Then" clause causes runtime error 3021 (Access 2003) Boris Microsoft Access 37 25th Aug 2004 07:32 PM
Bug: Empty "If Me.Recordset Is Nothing Then" clause causes runtime error 3021 (Access 2003) Boris Microsoft Access Form Coding 37 25th Aug 2004 07:32 PM


Features
 

Advertising
 

Newsgroups
 


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