R
RickCass
I would like to store values from a form (on close), and
then have those values reappear when the form opens. We
would like to store the values in a table.
Here is what I wrote thus far and am having some problems.
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 and values
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.XXX = storedbegdate
Then 'storebegdate is the name of the field in the table
adoRsSetNumber.Fields("storedbegdate") =
strStartDate
adoRsSetNumber.Update 'XXX
End If
'If adoRsSetNumber.Fields("storedenddate")
Then
' adoRsSetNumber.Fields("storedenddate") =
strEndDate
' adoRsSetNumber.Update
'End If
Loop
End sub
Look for the XXX, this marks my problems.
The first problem is I don't know how to compare and know
that I am in the right field when putting data in it.
The second problem is I don't know how to update the
table once I have stored the values.
Any help?
RickCass
(e-mail address removed)
then have those values reappear when the form opens. We
would like to store the values in a table.
Here is what I wrote thus far and am having some problems.
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 and values
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.XXX = storedbegdate
Then 'storebegdate is the name of the field in the table
adoRsSetNumber.Fields("storedbegdate") =
strStartDate
adoRsSetNumber.Update 'XXX
End If
'If adoRsSetNumber.Fields("storedenddate")
Then
' adoRsSetNumber.Fields("storedenddate") =
strEndDate
' adoRsSetNumber.Update
'End If
Loop
End sub
Look for the XXX, this marks my problems.
The first problem is I don't know how to compare and know
that I am in the right field when putting data in it.
The second problem is I don't know how to update the
table once I have stored the values.
Any help?
RickCass
(e-mail address removed)