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
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
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.
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?
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
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
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".
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??
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
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.
I am having this error which is driving me nuts but I am sure it is quite a simple one. I am attaching a Sample dbase - My command runs of a Form based on a Table. Any help??
I have a table with multiple records per individual.. I need to search through all of their results to flag up those in a query that do not match the approved list..
what is the best way to do this? I am trying a recordset loop but am struggling a bit...
here is my code so far
Private Sub Command0_Click() Dim rst As DAO.Recordset Dim dbs As DAO.Database Dim strSQL As String Dim strPscale As String
strSQL = "SELECT Eng_Speaking, Eng_speaking from qry_Sub1_crosstab_Crosstab;" Set dbs = CurrentDb Set rst = dbs.OpenRecordset(strSQL) Me.Text1 = ""
Do While Not rst.EOF strPscale = rst.Fields("Eng_Speaking") & ";"
rst.MoveNext
Loop Me.Text1 = strPscale Set rst = Nothing End Sub
but I need to somehow incorporate an array into this to check the score...
I am attaching current db below its not the best in the world but it suits me. lol anyway basically my problem is in the form frmAssignPatientMedication i basically want the user to select from the two combo boxes (a patient then a medicine) then click Assign and i want the database to add this info to the table tblPatientMedicine i cant seem to get my head around how the hell to do it! So any help will be greatly appreciated! Any other areas u think i could better in my db just say u'll probably be right! Thanks in advance:)
I have created a recordset and what i want to do is check the field value "SiteRAG" to see if it matches some criteria and if so do some action where the field "SiteID" = the same as a label on a form.
Please see CAPS in middle of code:
Dim db As Object Dim rs As Object Dim intCount As Integer, intRecordCount As Integer, intID As Integer Dim strSQL As String Dim strRAG As Long Dim fldItem As Field
strSQL = "SELECT tblSite.SiteID, tblSite.SiteRAG, tblSite.Active " _ & " FROM tblSite " _ & " WHERE (((tblSite.Active)=Yes));"
Set db = CurrentDb Set rs = db.OpenRecordset(strSQL)
intRecordCount = 0 rs.MoveFirst
CHECK THE FIRST ROW FIELD SiteRAG & IF = TO CRITERIA THEN DO SOMETHING BASED ON A LABEL MATCHING THE SiteID ELSE MOVE TO NEXT ROW
Hi...hope someone can help. I'm a bit new to the programming scene and need some help with a recordset.
The current code that I am using is:
Private Sub Command126_Click() 'September - 2006 - Create Application Form. Dim appWord As Word.Application Dim NoPrompt Dim rstContacts As Recordset Set rstContacts = Me.Recordset
Set appWord = GetObject(, "Word.Application")
With appWord .Documents.Add "C:Documents and SettingsAdministratorMy Documents est.doc" .ActiveDocument.ShowSpellingErrors = False .Selection.Goto wdGoToBookmark, Name:="test" End With
Do Until rstContacts.EOF
appWord.Selection.TypeText rstContacts!ContactName & " " rstContacts.MoveNext Loop End Sub
I want a situation where recordset information can be 'fed' to a word document depending on what is written in control boxes on the form. So, for example if there are three options in a Combo Box, namely:
Option 1, Option 2 and Option 3
I want information from the 'ContactName' control box to be inserted in the 'test' document at specific 'bookmarks' for all forms where 'Option 1' is selected in the Combo Box.
Hope this makes sense....I think I'm getting close but still no joy
Does anybody know how to use recordset.moveprevious? I'm using Access 2000. I want to use moveprevious function but it generates an error. Following are my codes and I've attached the error screen. Thanks a lot...
Private Sub cmdPrev_Click()
If rstProceeds.BOF <> True Then rstProceeds.Moveprevious End If End Sub
Below are my connection string Set rstProceeds = New ADODB.Recordset Set cmdProceeds = New ADODB.Command
I made a function to insert a record from one table into another table. Sometimes some of the fields are blank; so I included the Nz() function to deal with null fields. After eliminating the null errors with the Nz() statements, the function no longer inserts the record from one table to the other when one of the fields is blank. However, the function still works if all the fields have data. I can't seem to trace the change in the function that keeps it from working all the time. Can someone take a look at this and help me .......
I have a query 'QryCasesToWork' which identifies applications to work based on a complex set of criteria.
Once the query has run, I need a field called 'ToDo' to update to 'yes'. Unfortunately, one of the preceding queries which goes to make up QryCasesToWork is a Union query, meaning that all the subsequent results are non-updatable.
Is there an easy way to take the application numbers returned in QryCasesToWork, and update the appropriate ToDo fields in the table?
I had a vague thought of using a Make Table query form the results of QryCasesToWork then querying that table against my main table to update the field, but this seems to me to be a cumbersome and unwieldy solution.
Does anyone have the 'correct' solution? Any help greatly appreciated.
I'm having a problem updating a form. The query from the form is based on two other queries, one of these queries is based on a table from an external database.
I want to use the Form to populate only data on my own database using a checkbox with:
If IsNull (Me.ReceiptDate) Then ReceiptDate= ExternalReceiptDate 'where ExternalReceiptDate is the receipt date from the external table End If
I have checked to make sure that the "unique values" of the queries are all set to No.
As I will only be updating data to tables that are on my database that are updatable. I'm hoping that someone can offer some advice if this is possible and why I'm still getting "recordset not updatable" when trying to enter any data to my data fields in the form.
Hi, I know MS Access quite but not much. I am using Access 2000.
What I want to do is to use DLOOKUP Function to find a value stored in a recordset defined in VBA. I successfully did this task by creating a query.
You will say if I have done this then what is the problem. Dear I have to create as many queries as NO of forms as this query is required on every form on a controll when it is double clicked. Thus I want to create a function with my parameter which is "Date" of that form.
For testing I created this sub on my form but got an error .
Error message says ****Run Time Error '3061' ****Too Few parameters. Expected 1
I really am not able to get why this error is coming as I copied and pasted this SqlString created by MSAccess from my successful query .
================================== Dim rstTemp As Recordset Dim sqlStr As String
sqlStr = "SELECT tblJournal.Account AS AccID, Sum(tblJournal.amtDebit) AS Dr, Sum(tblJournal.amtCredit) AS Cr, tblCOA.OpBalDr, tblCOA.OpBalCr, [OpBalDr]+[Dr] AS Debit, [Cr]+[OpBalCr] AS Credit, [Debit]-[Credit] AS Bal FROM tblCOA INNER JOIN tblJournal ON tblCOA.accNum = tblJournal.Account WHERE (((tblJournal.Date) <= " & Me.Date & " )) GROUP BY tblJournal.Account, tblCOA.OpBalDr, tblCOA.OpBalCr;"
Set rstTemp = CurrentDb.OpenRecordset(sqlStr)
xx = DLookup("[Bal]", "rstTemp", "AccID=1010")
MsgBox xx
rstTemp.Close
================================ Please tell where I am wrong and how can I perform this task in a rather easier way.
I have a query that is set as a recordset. The query returns many values and one of the value is the Date field. How can I get the Last date value (as in the recent date entered in the sales table) and save it in a recordset.
Here is my code:
strSQL = "SELECT tblSales.* FROM tblSales;" Set rsQry = db.OpenRecordset(strSQL)
I need to get the last date field in a recordset, can this be done?
I am trying to check a “Check Box” on my query, but Access won’t allow me to do so as “This recordset is not updateable” - Could anyone please offer an idea of how I can get around this problem…..
I buy lots of products from a supplier, for each product ordered I assign an order ID, and have a check box called “Delivered” for each product to show whether it has been delivered or not. When the delivery arrives I print out our order onto paper and tick each product that has arrived, then I go onto the Access database and tick all of the boxes for the products that have arrived.
This way, any products that haven’t arrived and have not been checked show up on a query to show all products that have the “Delivered” field unchecked.
9 times out of 10 all of the products arrive, so I want to perform a group query on the order ID, and then check the box for the whole order to show that all the products arrived – rather than having to tick off each product (sometimes there can be up to 50 products, and I’ve already gone through the process once on paper so if they are all there I don’t want to have to do it all over again).
For example, the following shows the printed report for the order “1234”:
[Order ID] [Product ID] [Supplier ID] [Delivered] 1234 1 Supplier A NO 1234 2 Supplier A NO 1234 3 Supplier A NO 1234 4 Supplier A NO 1234 5 Supplier A NO 1234 6 Supplier A NO 1234 7 Supplier A NO 1234 8 Supplier A NO 1234 9 Supplier A NO
I’ve been through the delivery from Supplier A and all of the products are there. I perform a group query on the “Order ID”, “Supplier ID” and “Delivered” fields to return the following
[Order ID] [Supplier ID] [Delivered] 1234 Supplier A NO
I want to be able to tick the “Delivered” check box and it automatically check each “Delivered” box for the 9 products mentioned above.
Does anyone know if this is possible? I’ve spent ages going through the properties of the query, changing the Recordset Types and trying to use forms, and going through help files but I can’t find any options. I did come across the possibility of using an update query – however I don’t know how to perform a “Group By” total on the “Order ID”.
Any help or advice would be very much appreciated.
hi, I have recently started working in Access. In one of the forms, I am required to display data from the recordset in several controls on the form. Now the thing is, some of fields of the recordset, has data that I want to change before they are displayed on the controls (like, fields have abbreviated name of states, and in controls I want to display full name of corresponding state). But when make such change in the recordset, the data in the database also gets updated. I don’t want to change the data in the database? How can I do that?
And there is one more question. If I want to attach a control (which is a combo box), with one of the fields in the existing recordset, how would I do that?