From Code To Populate A Recordset

Jan 28, 2006

Hi,

I am trying to populate a recordset in
Access97 using the following code, but cannot
seem to get it to work.

The table name is "EventData" that has Type and date fields.
startdate and enddate are text boxes on a Form, for wich the user
enters the date range, and then clicks a command button to
build an Excel spreadsheet on the fly that will be populated with the
results of the recordseet.

here is the code:

Dim db As DAO.Database
Dim rst As DAO.Recordset

strSql = " SELECT EventData.EventType, Count([EventData].[EventType]) AS [Num Occurrences] FROM EventData WHERE ((EventData.Date) >= (Me!startdate)) GROUP BY EventData.EventType"


The error message that I am getting is "run time error 3061", too few paramaters. ALSO not sure if I need a semicolon right before the closing quote of strSql.

Any help is appreciated.

View Replies


ADVERTISEMENT

Can You Populate Table From Recordset??

Oct 28, 2004

hello there,

just curious if it was possible to populate an empty tables' fields from a recordset that had been defined earlier in VBA under the criteria of a bit of sql code?

cheers.

View 2 Replies View Related

ADO Recordset Populate Combo Box

Sep 26, 2005

hi all,

not sure if this is the correct forum but here goes. is it possible to have a disconnected ADO recordset populate a combo box in an Access Project (.adp)? i have a Access XP front end piping back to a SQL Server 2k dbase. i'm using a stored procedure to handle my insert, however i have a couple of combo boxes on my data entry form that i need to populate on the form's "OnLoad" event. i was wondering if i can populate these using a disconnected recordset (similar to functionality of the dataset object in ADO.NET)?

if not any ideas of best practices to populate combo boxes and limit connection resources?

many thanks for any suggestions.

View 5 Replies View Related

Populate List Box From Recordset

Oct 28, 2013

So Im trying to populate the listbox using string connection and having this error: "the object you entered is not a valid recordset property"

here's the code:
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Set cnn = New ADODB.Connection
cnn = "DRIVER={MySQL ODBC 5.1 Driver};SERVER=xxx;DATABASE=xxx;Port=xxx;USER=xxx; PASSWORD=xx;OPTION=3;"

[code]....

Where is the error??? am doing right or is there any better way to populate listbox from string connection.

View 8 Replies View Related

Binding Recordset To Report With VBA Code

May 5, 2005

Hy,i have some ADO recordset and i want to bind it to blank report that I made in reports.How to do this.
If i create report in reports section and after that i want to see it in my code as that same object and set his record or data source property how to do this??
I know that you can set the recordsource property directly in report but it includes some values from textbox in my form that doesn't show corectly(it's an array of numbers,and i don't know why it doesn't accept it).
Thanks

View 2 Replies View Related

Queries :: Using Recordset In VBA Code With Yes / No Datatype

Apr 18, 2013

I'm a having a problem with a Yes/No datatype. Fundamentally, my code looks like this:

strSQL = "SELECT * FROM tblAddresses " & _
" WHERE YPID = " & Me.Parent.IDNUMBER & " AND CurrentAddress = yes"

Set rs = db.OpenRecordset(strSQL)

Now this statement returns 3 records even though only 1 Current Address exists.

false also returns 3 records
true also returns 3 records
no also returns 3 records
-1 also returns 3 records
0 also returns 3 records
1 RETURNS 0 records!!

If I look at the table in Access, I only have 1 CurrentAddress record for my IDNumber.

View 1 Replies View Related

Queries :: SQL Code - Recordset Is Not Updateable?

Oct 4, 2013

I'm fairly new to SQL and I'm trying to input data into this form I've created but it tells me that "this Recordset is not updateable". Here's my SQL code, I'm not certain this is the problem though.

Code:
SELECT [Annual Instructor Report County Summary].*, [Camps, SS Events, Events, Total Members].*,
[Archery Members].[numArchClubs]+[Archery Members].[numArchNon4H]+[Archery Members].[numArchCamp]+
[Archery Members].[numArchSSEvent]+[Archery Members].[numArchEvent] AS totArchMem, [Rifle Members].

[Code] ....

View 6 Replies View Related

Queries :: Recordset Shows Nothing In The Code?

Aug 21, 2013

i have a combo box ,and when i should select "all",this button after update code should show me all the column of table test ,but looks like for no reason the record set shows nothing and its not working.

Code:

Private Sub cboTaskListName_AfterUpdate()
'On Error GoTo cboTaskListName_AfterUpdate_Err
Me.Refresh
Dim db As DAO.Database
Dim SQL As String
Dim rs As DAO.Recordset
If Me.cboTaskListName = "111111" Then
Set db = CurrentDb()
SQL = "SELECT no1 from test"
Set rs = CurrentDb.OpenRecordset(SQL, dbOpenDynaset)
End If
End Sub

View 1 Replies View Related

Modules & VBA :: Code That Populate Field

Feb 25, 2014

I am using MS Access 2010 and I am struggling to write some vba in my database. On my form, I have a Payment Type dropdown field.When someone selects a payment type I want the code to calculate the end date. Then populate the End Date field with the answer.I will be having a few payment types too, but for now on the dropdown I have two.2/Month and 24/Annum.

View 3 Replies View Related

Code To Populate Multiple Fields In One Sub Form From Another

Sep 6, 2006

I am looking to add multiple lines of record to a sub-form via a module activated from another linked sub-form.
As an example of what I want to do:
On identifying a particular type of vehicle servicing (e.g. 6000 mile service, 12000 mile service) on a service event sub-form of a vehicle form, I want to enter a list of required parts (e.g. oil filter, oil, etc) on another sub-form called "parts", that I can then edit before recording in an underlying table.
Can anyone help.
Thanks
Steve
:confused:

View 1 Replies View Related

Forms :: Lookup With Values From Another Table - Populate County Once Zip Code Entered

Mar 22, 2013

I want my form frmintake to lookup with values from another table and populare county once the zip codes has been entered.

I have a table called tblintake and another tblcounty.

tblintake has zip codes entered manually

tblcounty has zip codes and counties for all regions

how does this work out in dlookup.

=DLOOKUP[Zip Code],[tblCounty],[zip Code]=[County])

View 1 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

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

Please Review This Code, (simple Code) New With Codes

Feb 16, 2006

Works great, but when I hit the number "3", (3 times in row) it will let me into the form. I want it to not let me in IF I don't know the password.

Where did I go wrong?

Private Sub Form_Load()
Dim pw As Variant

If InputBox("What is the password?", "Password") = "1" Then
Else
MsgBox "Invalid Password", vbCritical, "Sorry Charlie"
DoCmd.Close
If InputBox("What is the password?", "Password") = "2" Then
Else
MsgBox "Invalid Password", vbCritical, "Sorry Charlie"
DoCmd.Close
End If
End If


End Sub

View 14 Replies View Related

Using Code To Unprotect And Protect Viewing Code

Jan 14, 2007

I protect my code from people being able to read it by setting a password on the code from Tools > Properties, selecting the Protection tab and entering a password, and clicking "Lock Project"

Is there a way to write code that will remove that Lock Project check and check it back on?

I've looked through the Application.SetOption command and it doesn't seem to be one of the choices. It would be very helpful if someone knew how to do this.

Thanks

SHADOW

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

Recordset Error

Apr 20, 2006

Hi,

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??

Thanks

View 6 Replies View Related

Array Recordset

May 31, 2005

Hi all,

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...

any ideas?

ta

John

View 4 Replies View Related







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