How Can I Get The Last Date Value In A Recordset

Dec 6, 2007

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?

Thanks,
Ket

View Replies


ADVERTISEMENT

Recordset To Update Date / Time

Dec 19, 2014

I am trying to have the code perform these things but unable to do so. While the code would still work, it will not move to the next user with either no date or the earliest date.

Goal:
-Go through the query record by record according to the date/time field
-Find the record with no date or earliest date (in that order)
-change its date to today's date

Code:

Code:
Private Sub Command56_Click() Dim i As Long
With Screen.ActiveForm.[AMID]
Dim LResponse As Integer
LResponse = MsgBox("Do you wish to auto-assign to an Accreditation Manager?", vbYesNo, "Continue")

[code]....

View 7 Replies View Related

Setting Date Field In Recordset To Null

Nov 15, 2014

Error 1: Setting Date Field in Recordset to null

Error 1: Setting Date Field in Recordset to null " data conversation error 3421 "

Solution: If the field is null set it back to itself .

Here is a simple dummy example i wrote to demonstrate the solution ( look for the bold text in side the code )

Code:
Sub Event_btnSaveEndTime ()
dim strEndDate as string
With Form_frmMainForm
strEndTime = .txtEndTime.Value

[code]....

View 3 Replies View Related

Modules & VBA :: String And Date - Data Type Mismatched In Recordset Filter

Jan 10, 2015

I am trying to filter a recordset with a variable q. The field in the table associated with the record set is of data type Date/time. I assigned data types String and Date to q but both cases generates the error message " Data type mismatched in expression".

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

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

Queries :: Date / Time Query - Return All Records Of Specified Date Or Date Range

Aug 19, 2015

I have a table that has entries recorded with date and time in one field, and I want to have a query that returns all records of a specified date or date range, regardless of the time in the field.

I have tried

Code:
Between [StartDate:] And [EndDate:]

And

Code:
Between [StartDate:] & "00:00" And [EndDate:] & "23:59"

Neither of which work ....

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

Recordset Problems??

Mar 17, 2006

Hi all,

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:)

View 2 Replies View Related

Loop Recordset

Jul 25, 2006

Hi folks,

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

Loop
rs.Close
db.Close


Thanks for any help
Mark

View 2 Replies View Related

Recordset / Listbox Help

Aug 16, 2006

First of all i'm a novice, so take it easy on me!

I have an access 2000 database with multiple tables and forms.

within one of my forms I wish to populate a listbox (listbox1) with values from a recordset (myRS) that I have created from a SQL query.

Function PopList()
Dim dbs As Database
Dim strSQL As String
Dim myRS As Recordset

Set dbs = CurrentDb
strSQL = "SELECT * FROM customer"
Set myRS = dbs.OpenRecordset(strSQL, dbOpenSnapshot)

'Populate listbox with recordset 'myRS'
' ???

End Function

All I want to do is populate the listbox with values from the recordset (binding or snapshot - I don't really mind, either will do)

How difficult can this be:mad:

Any help much appreciated to get me over this hurdle:confused:

CraigDiver

View 11 Replies View Related

Recordset Query

Sep 19, 2006

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

Thanks

Chris

View 5 Replies View Related

Does Anybody Knows How To Use Recordset.moveprevious

Sep 22, 2006

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

sSQL = "SELECT * " & _
"FROM [AUC] " & _
"WHERE((([AUC]].[STATUS]) = ""SOLD"" "


cmdProceeds.CommandText = sSQL

cmdProceeds.CommandType = adCmdText
cmdProceeds.ActiveConnection = CurrentProject.Connection

If sSQL <> "" Then
Set rstProceeds = cmdProceeds.Execute
If rstProceeds.EOF <> True Then
Call GetAFData
End If

End If

View 2 Replies View Related

Recordset Problem

Feb 23, 2005

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

View 1 Replies View Related

RecordSet For A Table

Aug 14, 2006

Can anyone help me to create an accumulative balance in a table if the invoice is the same. For example:

Inv # Transaction Amount Balance
123456 10 10
123456 20 30
123456 15 45
321654 10 10
321654 35 45
321654 10 55

Thanks

View 2 Replies View Related

Recordset Not Updatable

Nov 11, 2005

krispi (MIS) 11 Nov 05 9:36
Hi all

I have a database of mortgage applications.

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.

Thanks
Chris

View 3 Replies View Related







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