Querynot Working When Opening Into A Recordset

Nov 1, 2006

Hello all,

I have a a form which I use to populate query parameters and send the result to MS Word, where a table is created from the query. The form contains 2 controls: 1) a combo box containing the month number and 2) a text box containing a year value. The form also contains a command button that opens the query into a recordset and then creates the Word table.

The query (qryCostData) contains 2 fields that reference these form parameters. The query works when:

I open the query directly (query window) while the form is open w/ the month and year parameters selected
I open the query directly (query window) when the form is closed but the month and year parameters are hard-coded into the query
I open the query using the command button on the form when the month and year paramters are hard-coded into the query


The query does not work when I open the query using the command button on the form and the query containes references to the month and year parameters from the form. The following error is returned on the following command:

command: rst.open "qryCostData", CurrentProject.Connection

error:

Run-time error: -2147217900 (8004e14)

Invalid SQL statement; expected DELETE, INSERT, PROCEDURE, SELECT, or UPDATE


Any ideas on why it works using the form command button when the parameters are hard-coded but not when referencing the form fields? If I open the form and select the parameters and then open the query through the query window, it works fine.

Thanks in advance.

Ken

View Replies


ADVERTISEMENT

Help Opening A Recordset

Jun 30, 2005

When attempting to open a recordset, I get "Run-time error '3709': The connection cannot be used to perform this operation. It is either closed or invalid in this context."

Any suggestions would be greatly appreciated.


Public Function GetTickets(ID, NbrTickets)

Dim rsTicket As ADODB.Recordset
Dim rstAPs As Object
Dim strQry As String

Dim cnnDB As ADODB.Connection
Set cnnDB = CurrentProject.Connection

'Determine how many tickets have already been assigned...
strQry = "SELECT count([ticket number]) as nbr FROM Tickets " _
& "WHERE [Tickets]![MailList ID] = " & ID & ";"

MsgBox (strQry)

Set rsTicket = New ADODB.Recordset
rsTicket.Open strQry


With rstTicket
.MoveFirst
AssignedTiks = rstTicket!nbr 'This is the query result
End With

MsgBox ("Number of assigned tickets is " & AssignedTiks)

If AssignedTiks = NbrTickets Then
'nothing
MsgBox ("Nothing")
Else
If AssignedTiks > NbrTickets Then
MsgBox ("Remove Tickets")
'Remove Tickets
Else
'Add Tickets
MsgBox ("Add Tickets")
End If
End If

End Function

View 1 Replies View Related

Help With Opening ADO Recordset

Jun 14, 2007

I am using the following code to create a ADO recordset. The table in which the SQL refers to is in a front end database where the table is linked to the backend. I have just recently experimenting with ADO and need some help. The following code give me and error "Method 'Open' of '_object' failed. Is there a different way to crate a ADO recordset when the table is located in the backend. Please help

Private Sub Form_Load()
Dim mysql As String
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim PersonnelInfo As String


mysql = "SELECT tbl_Personnel.last, tbl_Personnel.RANK, tbl_Personnel.SECTION " & _
"FROM tbl_Personnel " & _
"WHERE (((tbl_Personnel.RANK)='lt') AND ((tbl_Personnel.SECTION)=[Forms]![sos Personnel]![SchShiftFind]));"


Set rs = New ADODB.Recordset
Set conn = CurrentProject.Connection

rs.Open mysql, conn, adOpenKeyset, adLockOptimistic

PersonnelInfo = rs("last")
Me.Lt1 = PersonnelInfo
End Sub

View 3 Replies View Related

Opening A Report With Recordset Data

Nov 3, 2004

I have looked through the threads and have not found an answer to my question, so I post it hoping there is an answer as well as documenting useful information for other individuals.

The following code is what I am using to 'pull' data in order to print a certificate. It functions the way I designed it (verified by debug.prints and msgboxes). My question is how do I pass data to a defined report (certificate) based upon the results of a built recordset. When the report opens, the values come up as "#Name?". I'm guessing that the issue is syntax, but I just don't know. Here is the code I have so far (I've even commented it for y'all)...

Looking forward to your comments...

-BT.

Dim RSAgg As Recordset
Dim RSsrc As Recordset
Dim DB As Database
Dim strAgg As String
Dim strSQL As String
Dim strCert As String

'If there is no week number set, drop out
If Not IsNumeric(txtWeekNum) Then
MsgBox "You Must Specify a Week Number.", vbInformation + vbOKOnly, "Required Input"
Exit Sub
End If

' tblAggDesc contains the field names
' that have scores I want to evaluate.
' If someone makes a perfect score,
' then they get a certificate. Fields are
' a1, a2, a3, b1, b2, b3, c1, c2, c3.
strAgg = "SELECT tblAggDesc.AggCourse, tblAggDesc.AggDesc FROM tblAggDesc;"

Set DB = CurrentDb()
Set RSAgg = DB.OpenRecordset(strAgg)

RSAgg.MoveFirst
Do While Not RSAgg.EOF
If (Right(RSAgg!AggCourse, 1) > 1) Then 'rounds 2 & 3 contain additional information that is printed on certificate
strSQL = "SELECT tblScores.HEDR, tblRoster.Fname, tblRoster.Lname, tblScores.WeekNo, tblScores." & RSAgg!AggCourse & ", tblScores." & RSAgg!AggCourse & "X AS AggCourseX " & _
"FROM tblRoster LEFT JOIN tblScores ON tblRoster.HEDR = tblScores.HEDR " & _
"WHERE (((tblScores.WeekNo)=" & [txtWeekNum] & ") AND ((tblScores." & RSAgg!AggCourse & ")=100));"
Else
strSQL = "SELECT tblScores.HEDR, tblRoster.Fname, tblRoster.Lname, tblScores.WeekNo, tblScores." & RSAgg!AggCourse & " " & _
"FROM tblRoster LEFT JOIN tblScores ON tblRoster.HEDR = tblScores.HEDR " & _
"WHERE (((tblScores.WeekNo)=" & [txtWeekNum] & ") AND ((tblScores." & RSAgg!AggCourse & ")=100));"
End If

Set RSsrc = DB.OpenRecordset(strSQL, dbOpenDynaset)
If Not (RSsrc.BOF And RSsrc.EOF) Then
RSsrc.MoveFirst
Do While Not RSsrc.EOF
If (Right(RSAgg!AggCourse, 1) > 1) Then
strScore = RSsrc!AggCourseX & "X"
Else
strScore = ""
End If
'MsgBox RSsrc!Fname & " " & RSsrc!Lname & " " & RSsrc!WeekNo & " " & RSAgg!AggCourse & " " & strScore & " " & RSAgg!AggDesc
strCert = "Fname='" & RSsrc!Fname & "' AND Lname='" & RSsrc!Lname & "'" & " AND WeekNo='" & RSsrc!WeekNo & "' AND XCount='" & strScore & "' AND AggDesc='" & RSAgg!AggDesc & "'"
'Debug.Print strCert

' this is the point that I have problems.
' I want to pass RSsrc!Fname,
' RSsrc!Lname, RSsrc!WeekNo,
' RSsrc!AggCourseX, RSAgg!AggDesc to
' the report.
DoCmd.OpenReport "rptCleanTarget", acViewPreview, , strCert

RSsrc.MoveNext
Loop
End If

RSsrc.Close
RSAgg.MoveNext
Loop

RSAgg.Close
Set DB = Nothing

View 6 Replies View Related

Modules & VBA :: Opening ADODB Recordset

Jul 2, 2013

I'm building a lab environment into one of my projects. I'm testing the distribution of values over a largish number of attempts to create a unique value.I have a table called LAB_UniqueIDTest, with two fields:

LAB_ID - the string value being tested, and
LAB_UsageCount - the number of times the value has been created.

I'm trying to open the table using the following code:

Code:

' Initialize access to the LAB_UniqueIDTest table
Set rs = New ADODB.Recordset
rs.Open "LAB_UniqueIDTest", _
CurrentProject.Connection, _
adOpenKeyset, adLockOptimistic

I have similar snippets of code all over the application - either with a literal (as here) or as a string parameter.I do not, ever, use the options parameter of rs.open.I get error message "Run time error -2147217900 (80040e14) Invalid SQL statement - expected DELETE, INSERT, PROCEDURE, SELECT or UPDATE

My guess is it's because somehow the Open procedure is trying to interpret the tablename as a SQL statement. But how come it isn't this obtuse at other times?

View 6 Replies View Related

Modules & VBA :: Opening A Recordset Based Upon A Variable?

Jul 5, 2013

Simple example is I have say 3 recordsets open (they are opened once as they are refered to many times) - they are open early in the form (in this example 3 price lists that are applicable for a customer) (if the syntax of the select is slightly wrong I'm just showing to 'prove' the concept).

Dim db As Database
Dim rs1 As Recordset
Dim rs2 As Recordset
Dim rs3 As Recordset
Set db = CurrentDb()
Set rs1 = db.OpenRecordset("SELECT * FROM Prices WHERE (((Prices.ID)=1));")
Set rs2 = db.OpenRecordset("SELECT * FROM Prices WHERE (((Prices.ID)=2));")
Set rs3 = db.OpenRecordset("SELECT * FROM Prices WHERE (((Prices.ID)=3));")

What I want to do is have a central function that I can pass a list I wish to process/do something with aka. The 3 recordsets are the same except for the where criteria.

private sub GETPRICEFROMLIST(pricelist as long)

dim rs as recordset

set rs = Recordset("rs" & pricelist)
.....

I put the above to show what I'm trying to do but of course that doesn't work There won't be any updates to these recordsets only reading of data.

View 6 Replies View Related

Modules & VBA :: Working With Recordset - Is There A Cache That Needs To Be Cleared?

Nov 4, 2014

I have a Public Function that is being auto executed when my database opens. It is designed to change the value of a record from "Trailing" to "Critical" when the record is older than 90 days. Everything works as expected initially by changing the status and adding some text to a comment field for tracking purposes. However, I manually flipped the status of those records back to "Trailing" for continued testing purposes and they are no longer being included in the code execution. Do recordsets have a cache that is identifying these records as already having been updated and is, therefore, excluding them for all future executions of this module? Code is below. I added a counter just for the purposes of testing and it's counting zero records, even though there are several records that meet the necessary criteria.

Public Function Trailing()
Dim strSQL As String
Dim db As Database
Dim rs As Recordset
Dim i As Integer
Dim ND As Date
Dim CT As Integer

[code]...

View 7 Replies View Related

Access 2013 Stops Working With Recordset

Jan 6, 2015

I have a database with a table and 2 forms.One form (frmList) is a list of all records in the database, and the other form (frmInput) displays fields for a single record.There is a button in frmList which runs the following script. The user clicks a record in frmList, clicks the button, and the selected record opens in frmInput. ID is a text field containing digits and an alpha that is in both frmList and frmInput.

Code:
Private Sub Command9_Click()
Dim ID As String
strCriteria = "ID = '" & Me.ID.Value & "'"
DoCmd.OpenForm "frmInput", acNormal
Form_frmInput.Recordset.FindFirst strCriteria
End Sub

This script works as expected in Access 2010. However we recently upgraded to Access 2013 and since then, this script causes Access to crash ("Access has stopped working..." dialog appears).I have stepped through the script and the line causing the crash is

Code:
Form_frmInput.Recordset.FindFirst strCriteria

I can't find any problems with syntax or anything about Recordset.Findfirst being deprecated in 2013 so I suspected some kind of file corruption. To resolve this I have tried: Compacting and repairing the databaseDecompiling and recompiling the VBA modulesCreating a fresh database and copying all the objects into it

could this be due to a missing library or something? Are there other methods of resolving a corrupt database if that is the problem? Or as a last resort is there an alternative method to Recordset.FindFirst that I can use to open a form to a particular record while retaining the ability to navigate through other records?

View 9 Replies View Related

Modules & VBA :: Calendar Entries - Opening Recordset Based Off Of SQL String

Oct 30, 2014

I am currently developing a calendar and am trying to open a recordset based off of a SQL string. When I deleted the Where part of the SQL statement, the code ran fine. So I am pretty sure that the problem lies within the Where part of the code. I use this code to filter my query based on txtTaskTypeID but if the value is null then the query is suppose to return all values. I keep getting Run-time error"3061: Too few parameters. Expected 1".

Code:
strSQL = "SELECT tbl1CalendarEntries.ID, tbl1CalendarEntries.Title, tbl1CalendarEntries.StartDate, tbl1CalendarEntries.StartTime, " _
& "tbl1CalendarEntries.EndDate, tbl1CalendarEntries.EndTime, tbl1CalendarEntries.TaskTypeID " _
& "FROM tbl1CalendarEntries " _
& "WHERE (((tbl1CalendarEntries.TaskTypeID)" _
& " Like IIf(IsNull([forms]![frmProductionPlanning]![txtTaskTypeID])=True,""*"",[forms]![frmProductionPlanning]![txtTaskTypeID]))) "
& "ORDER BY tbl1CalendarEntries.Title;"

View 5 Replies View Related

Modules & VBA :: How To Extract Recordset From Subform Into Recordset Object

Aug 14, 2015

Special situation: The SQL Server Linked Server across the country is linked to a Read Only Oracle DB. This data pull works perfectly and populates the Subform.

The problem is that Oracle can take 3 to 6 seconds to retrieve the single record depending on the network traffic through a small pipe.

The code below shows the RecordSource for the SubForm. clicking on a list box supplies the value. Then 3 to 6 seconds later, the subform populates.

The actual Recordset for this Recordsource is needed to conduct Validation on each field. Normally this would be on SQL Server, I might just create a Recordset Oject and run this SQL statement again in 1 milisecond. In this case, it will probably take an additional 3 to 6 seconds. Avoiding another lengthy round-trip to Oracle would be prefered.

Goal: How does one grab, clone, or other wise reference the existing recordset for the SubForm?

Note: Immediate Window - One single field can be returned quickly

There are 48 fields that need validation - is there a way to reference the entire recordset?

Immediate Window during Break Mode:
? me.fsubsrNavSHLBHL("NavSH_QQ")
NESE ' this is the correct value for the current recordsource

Set a breakpoint right after the line:
fsubsrNavSHLBHL.Form.RecordSource = "Select * from vsrNavigatorSHLBHL where Well_ID =" & txtNavWellID.Value

Immediate Window:
? me.fsubsrNavSHLBHL.Form.RecordSource
Select * from vsrNavigatorSHLBHL where Well_ID =91229

View 4 Replies View Related

Does A Filtered Mdb Recordset Still Bring Down The Whole Recordset?

Apr 27, 2007

Hi guys, I'm a bit confused: I know that opening a bound form will bring down the whole recordset. But if I create a parametered query as the recordsource, will it still bring down the whole recordset first and only afterwards cut down to the records matching the parameters?

Example: I have a clients table with 5000 clients on a backend mdb, and my client lookup form in my frontend mdb. If I open the form looking for just client "Jim Jones" (via the parameter query), will Access bring down all 5000 clients from the backend to my frontend first, and only then seek out "Jim Jones" before discarding the rest of the recordset?

For if this is true then this whole Access business is rather unsuited for networks, even a small one. I hope you guys prove me wrong.

Premy

View 14 Replies View Related

Modules & VBA :: Can Use Result Of One Recordset For Other Recordset

Jul 7, 2013

I want to write a email where there are 2 or 3 different ordernumbers for same email, i want to include the email in the mail part as single column table. how to do it? also can i use result of one recordset for other recordset?

View 1 Replies View Related

Forms :: Closing Opening Form With Timer Then Opening Main Menu

Apr 7, 2014

I have a Form opening from Access Options. I would like to close this Form using the Timer. The following is the code I have used but it is not working.

Private Sub Cover_Page_Form_Load()
OpenTimer = Timer
End Sub
Private Sub Cover_Page_Form_Timer()
If (Timer - OpenTime) = 5 Then DoCmd.Close acForm, "Cover_Page_Form", acSaveYes
End Sub

Next question. If I can get this to work can I then use a DoCmd to open new Form within the code above or do I need a new process.

View 5 Replies View Related

Opening Forms Directly (instead Of Opening MS ACCESS)

Apr 20, 2006

Hi All,

Is there a way that when the user clicks on a database file, the form pops up without opening MS Access window.

Thx,

Jatz

View 1 Replies View Related

Opening Forms Directly (instead Of Opening MS ACCESS First)

Apr 20, 2006

Hi All,

Is there a way that when the user clicks on a database file, the form pops up without opening MS Access window.

Thx,

Jatz

View 6 Replies View Related

Create A Recordset From A Recordset

Aug 17, 2007

from a table with fields userID and Date (in which any userID has multiple records with different Date values, and other fields) i have built a select query based on Date = one specific value. can anyone give an explanation (for beginners), through a sample code, that expands the query recordset so that the new recordset includes all records per userID that qualified in the prior recordset? below is an example. thank you!

Table with records:
userID / Date
u1 / d1
u1 / d2
u2 / d1
u2 / d2
u3 / d2
...
1st Select Query (where Date = d1):
u1 / d1
u2 / d1

Desired 2nd Query based off 1st Query (where ?):
u1 / d1
u1 / d2
u2 / d1
u2 / d2

View 3 Replies View Related

Updating One Recordset Using Another Recordset?

Jan 21, 2015

I have two tables that have the exact same fields. In table1 I have records that need to be UPDATED into table2. I tried an Update query and out of 600 records only half of those got updated. In my update query I joined tbl1 and tbl2 by Location (LOC) I checked for Nulls, Blanks, spaces, you name it. I can't figure why they all didn't get updated. I created a SQL query and go the exact same results. Ideally, I would like to create something in VBA to do this. I do not have any forms linked to these tables. In all I have about 600 records and 15 different fields that need to be updated. My example is only for one field.

sql example below. Which is the Access Sql in the Query

sql = "UPDATE tbl2 INNER JOIN tbl1 ON tbl2.LOC = tbl2.LOC" & _
"SET tbl2.Name = tbl1!Name" & _
"WHERE (((tbl2.Name) Is Null));"

Example.

Table1
Field1.Names = John

Table2
Field1.Names = "Need to UPDATE the name 'John' here"

I tried the Recordset .EDIT but I couldn't get it to work using two tables.

View 4 Replies View Related

Program Working In Access 2007 Not Working In Access 2010 Due To Missing OCX File

Dec 27, 2014

I have a program that runs under access 2007 that I use at my work. We will soon be updating to MS office 2010 and the program will not work now because a calender file .ocx was removed from access 2010. Is there a way to get the 2007 .ocx file to work in access 2010?The program I am using is a relatively simple stand-alone and unsupported app that we use to request patient arrival and departure from various radiology tests inside a hospital. No reports are made from the app other than the number of patient transports for the day.

The app is placed on a common drive accessed from any pc in the hospital. No special permissions are required. But our app does use the calendar, time and date functions in access 2007. When I tried the app on a pc with access 2010, it basically says it (access) cannot open the app because a .ocx file is not present.Is there a way to make the access 2010 calendar file work in access 2007?

View 1 Replies View Related

Duplicate Record Command Button Not Working For One Form But Is Working For Other Form

Jan 15, 2015

I have an Access 2010 database with two tables and two forms. The tables are Organizations and People. Similarly, the forms are Organizations Entry Form and PeopleEntryForm. The People are linked to the Organizations table. Several people can be linked to the same organization.On my Organizations EntryForm, I created a command button to duplicate a record using the wizard. It works fine.

I did exactly the same thing on the PeopleEntryForm, but instead of copying the record, it creates a new blank record. I don't get any error messages. Is my problem due to the fact that the People table is linked to the Organizations table?

View 13 Replies View Related

Opening An Access Program Without Opening Microsoft Access

Jun 11, 2007

I am very close to completing a DB Program.... How can I create a desktop Icon that will Launch my Program without Loading Microsoft Access along with it???

View 6 Replies View Related

Recordset Help

May 9, 2006

I'm a bit daft when it comes to recordsets to update a table.

I've searched the forum and can't find what I need. I was hoping I could find help here.

Below is my code I'm trying to use to update two tables. I use a query to get the SQL I needed, but it still isn't working.

I'm updating the tables from fields on an unbound form.

Thanks in advance.


Private Sub cmdAddEntry_Click()
On Error GoTo Err_cmdAddEntry_Click
Dim strSQL As String

Dim cnCurrent As ADODB.Connection
Set cnCurrent = CurrentProject.Connection

Dim rsRecordset As ADODB.Recordset
Set rsRecordset = New ADODB.Recordset


rsRecordset.ActiveConnection = CurrentProject.Connection
rsRecordset.LockType = adLockOptimistic
rsRecordset.CursorType = adOpenForwardOnly



strSQL = "UPDATE tblClaims INNER JOIN tblRCN ON tblClaims.intClaimID = tblRCN.intClaimID" & _
"SET tblClaims.strClaimNumber = [frmLogEntry].[txtClaimNumber], " & _
"tblClaims.strPatientID = [frmLogEntry].[txtPatientID], " & _
"tblClaims.strClaimType = [frmLogEntry].[txtClaimType], " & _
"tblClaims.dtmCancelDate = [frmLogEntry].[txtCancelDate], " & _
"tblClaims.dtmProcessDate = [frmLogEntry].[txtProcessDate], " & _
"tblClaims.strGroupName = [frmEntryLog].[txtGroupName], " & _
"tblRCN.curPaymentExpected = [frmEntryLog].[txtPaymentExpected], " & _
"tblRCN.curPaymentReceived = [frmEntryLog].[txtPaymentReceived], " & _
"tblRCN.strRCNNumber = [frmEntryLog].[txtRCN];"


rsRecordset.AddNew strSQL

rsRecordset.Update
rsRecordset.Close






Exit_cmdAddEntry_Click:
Exit Sub

Err_cmdAddEntry_Click:
MsgBox Err.Description
Resume Exit_cmdAddEntry_Click

End Sub

View 14 Replies View Related

ADO Recordset

Aug 25, 2006

I am using Access 2003/sp2
I have used this method to access tables directly that are in the same mdb as the form but all of a sudden the recordset open method will not work:

Dim recset1 As Recordset
Set recset1 = New ADODB.Recordset

With recset1
.Open "tbl_WasteReportRecs", CurrentProject.Connection, adOpenDynamic, adLockPessimistic
.AddNew
.Fields("Machine_ID") = Me.lst_Machine.Value
.Fields("Date") = Me.Calendar1.Value
.Fields("WasteCode_ID") = Me.Lst_WasteCode.Value
.Fields("Shift") = Me.lst_Shift.Value
.Fields("Employee_ID") = Me.lst_Employee.Value
.Fields("WasteWeight") = CInt(Me.txt_Weight.Text)
.Update
.Close
End With

A clue is when I start typing Dim test as Rec I get two Recordset choices
I can choose either one
Then after I type Set test = New ADODB.Recordset
Then I just do test. and Open does not appear just OpenRecordset
It is like the Open Method is not available in my collection
I have removed ADO 2.1 Reference and added 2.8 but that did not fix
If I open a project that I created earlier (possibly in earlier version of Access) the Open method is avalable when I "test".

View 1 Replies View Related

ADO Recordset

Mar 17, 2005

I am trying to add a new record to an existing table using ADO recordset. i have always used DAO before this and am quite ignorant about ADO methods...
this is what i am doing (my table is called 'Transmittals'):
Code:Private Sub cmd_savetrans_Click()'Error Handling On Error GoTo cmd_savetrans_Click_Err' Declare Variables Dim rs As ADODB.Recordset 'Dim sSQL As String ' Update Database Set rs = New ADODB.Recordset rs.Open "Transmittals", CurrentProject.Connection, adOpenStatic, adLockOptimistic rs("Transnumber") = Me.txt_transnum rs("Source") = Nz(Me.txt_source, "") rs("description") = Nz(Me.txt_transdesc, "") rs("Recddate") = Me.txt_transrecdate rs("transdate") = Me.txt_transdate rs("calcs") = Me.cbx_calcs' Message box MsgBox Me.txt_transnum & " added." ' Clear recordset Set rs = Nothing
with this, when i click the command button, i get the message "xxxx added." But nothing gets added to the table!
can someone guide me through this??

Thanks a ton!

View 2 Replies View Related

DAO.Recordset

Oct 7, 2005

I am working on an access project that connects to sql server 2000 using DAO. I am running into a problem with a combo box that has data bound to it. Basically when a user selects an item in the combo box I query the sql data using a linked table, but the recordset always comes back as read only so I can't edit the data. Any ideas on what may be the problem?

Dim qdf As DAO.QueryDef
Dim rs As DAO.Recordset
Dim SetID

SetID = DLookup("RateSet", "qselFwdrSets", "cusnum=0" & DLookup("cusnum", "dbo_tblOrders", "OrderID=" & OrderID))

Set qdf = CurrentDb.QueryDefs("qselOrderExtraRatesForFunc")
qdf.Parameters("pOrderID") = OrderID
qdf.Parameters("pRateType") = RateType

Set rs = qdf.OpenRecordset()

If rs.BOF And rs.EOF Then
'' didn't added yet
rs.AddNew
Else
'' recalculate
rs.Edit
End If

View 5 Replies View Related

Recordset.EOF

Dec 10, 2005

I've got a command button that goods thru all the records in a form to make an update:

DoCmd.GoToRecord , , acFirst
Do Until Me.Recordset.eof
If Me.invprint.value = true then
Me.invprint.value=false
End If
Docmd.Gotorecord,,acnext

Loop

It work but I get an error at the end, "You can't go to the specified record"

I'm guessing this mean that the Recordset.EOF is not identifying the last record. Is there a way around this? Is the Recordset.EOF only suppose to be used with Table and Queries? I try to just Resume thru the Error but anything freezes up.

View 1 Replies View Related

ADO Recordset Help

Dec 13, 2007

Hello,

Having a problem with my recordset. I have the vba code creating it using adodb.recordset. Problem is its coming up with no records. If I output the strSQL and paste it in an access query and run it, its fine and brings up all the records it should. I must be missing something or have something wrong for vba ? Below is the code. If you see anything off the bat let me know. I have also tried adOpenForwardOnly and get the same results, in fact tried all the Open types with no luck. Thanks so much.

Code:varpar1 = IIf([Forms]![frm_report_Benefits_Log]![checkbox_posted] = False, "(tbl_ARdata_ACF_Flagged.closed_flg) Like '*'", "(tbl_ARdata_ACF_Flagged.Closed_Flg) = True")varpar2 = IIf([Forms]![frm_report_Benefits_Log]![checkbox_inprocess] = False, "(tbl_ARdata_ACF_Flagged.closed_flg) Like '*'", "(tbl_ARdata_ACF_Flagged.Closed_Flg) = False")varpar3 = IIf(IsNull([Forms]![frm_report_Benefits_Log]![combo_region]), "(tbl_ARdata_ACF.region_code) Like '*'", "(tbl_ARdata_ACF.Region_Code) = [Forms]![frm_report_Benefits_Log]![combo_region]")varpar4 = IIf(IsNull([Forms]![frm_report_Benefits_Log]![combo_area]), "(tbl_ARdata_ACF.area_code) Like '*'", "(tbl_ARdata_ACF.Area_Code) = [Forms]![frm_report_Benefits_Log]![combo_area]")varpar5 = IIf(IsNull([Forms]![frm_report_Benefits_Log]![combo_reason_main]), "(tbl_Reason_Codes_lookup.Reason_Code) Like '*'", "(tbl_Reason_Codes_lookup.Reason_Code) = [Forms]![frm_report_Benefits_Log]![combo_reason_main]")varpar6 = IIf(IsNull([Forms]![frm_report_Benefits_Log]![combo_reason_sub]), "(tbl_Reason_Codes_lookup.Reason_ID) Like '*'", "(tbl_Reason_Codes_lookup.Reason_ID) = [Forms]![frm_report_Benefits_Log]![combo_reason_sub]")varpar7 = [Forms]![frm_report_Benefits_Log]![field_from_date_hidden]varpar8 = [Forms]![frm_report_Benefits_Log]![field_to_date_hidden]strSQL = "SELECT tbl_ARdata_ACF.ACF_ID, tbl_ARdata_ACF_Attachments.Attachment_Link FROM tbl_ARdata_ACF_Attachments RIGHT JOIN ((tbl_ARdata_ACF INNER JOIN tbl_ARData_ACF_Flagged ON tbl_ARdata_ACF.ACF_ID = tbl_ARData_ACF_Flagged.ACF_ID) INNER JOIN tbl_Reason_Codes_lookup ON tbl_ARdata_ACF.Reason_Code = tbl_Reason_Codes_lookup.Reason_ID) ON tbl_ARdata_ACF_Attachments.ACF_ID = tbl_ARData_ACF_Flagged.ACF_ID" _& " WHERE ((tbl_ARdata_ACF.Business_Number)=200) AND ((tbl_ARData_ACF_Flagged.Creation_Date) Between #" & varpar7 & "# And #" & varpar8 & "#) AND (" & varpar1 & ") AND (" & varpar2 & ") AND (" & varpar3 & ") AND (" & varpar4 & ") AND (" & varpar5 & ") AND (" & varpar6 & ") GROUP BY tbl_ARdata_ACF.ACF_ID, tbl_ARdata_ACF_Attachments.Attachment_Link ORDER BY tbl_ARdata_ACF.ACF_ID;" Set cnn = CurrentProject.Connection Set rst = New ADODB.Recordset rst.Open strSQL, cnn, adOpenStatic, adLockReadOnly varlinkcount = rst.RecordCount MsgBox varlinkcount 'Start - Print all code If rst.EOF Then MsgBox "no records?" End If

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved