R
RickCass
I need to update two fields in a table from a sub
routine.
Here is what I am trying to do, I am know there is a more
effecient way to do this (One that works).
Private Sub cmdExitForm_Click()
Dim strSQL, strStartDate, strEndDate As String
Dim adoRsSetNumber As New ADODB.Recordset
Dim adoCon As New ADODB.Connection
With adoCon
.Open CurrentProject.Connection
End With
' get all records from tblInformationTracking table
strSQL = "Select * from tblInformationTracking"
adoRsSetNumber.Open strSQL, adoCon, adOpenDynamic,
adLockOptimistic
'Use form frmMainMenu
With Form_frmMainMenu
strStartDate = .txtStartDate.Value
strEndDate = .txtEndDate.Value
End With
'move to first record in recordset
adoRsSetNumber.MoveFirst
' update storedBegDate and storedEndDate in table
tblInformationTracking
Do Until adoRsSetNumber.EOF
'get field name and look for storedBegDate
then store strStartDate
If adoRsSetNumber = storedbegdate Then
adoRsSetNumber.Fields("storedbegdate") =
strStartDate
adoRsSetNumber.Update
End If
'If adoRsSetNumber.Fields("storedenddate")
Then
' adoRsSetNumber.Fields("storedenddate") =
strEndDate
' adoRsSetNumber.Update
'End If
Loop
End Sub
routine.
Here is what I am trying to do, I am know there is a more
effecient way to do this (One that works).
Private Sub cmdExitForm_Click()
Dim strSQL, strStartDate, strEndDate As String
Dim adoRsSetNumber As New ADODB.Recordset
Dim adoCon As New ADODB.Connection
With adoCon
.Open CurrentProject.Connection
End With
' get all records from tblInformationTracking table
strSQL = "Select * from tblInformationTracking"
adoRsSetNumber.Open strSQL, adoCon, adOpenDynamic,
adLockOptimistic
'Use form frmMainMenu
With Form_frmMainMenu
strStartDate = .txtStartDate.Value
strEndDate = .txtEndDate.Value
End With
'move to first record in recordset
adoRsSetNumber.MoveFirst
' update storedBegDate and storedEndDate in table
tblInformationTracking
Do Until adoRsSetNumber.EOF
'get field name and look for storedBegDate
then store strStartDate
If adoRsSetNumber = storedbegdate Then
adoRsSetNumber.Fields("storedbegdate") =
strStartDate
adoRsSetNumber.Update
End If
'If adoRsSetNumber.Fields("storedenddate")
Then
' adoRsSetNumber.Fields("storedenddate") =
strEndDate
' adoRsSetNumber.Update
'End If
Loop
End Sub