C
c.kurutz
Hi. I am working on an Access database that someone else developed.
I have the following code in the database. I need to modify the SQL
string statement to also prompt for a date range based on the
"carddate". Any help would be greatly appreciated:
Private Sub changecpw_Click()
Dim ilong As Long
Dim retval As Long
Dim holdthis As Long
Dim tempquerydef As QueryDef
Dim tempdb As Database
Dim sqlstring As String
Dim matchthis As String
Dim newtext As String
Dim ctrlarray(1 To 2) As Control
retval = 0
holdthis = 0
For ilong = 1 To 2
retval = isvalid(ilong, ctrlarray())
If retval Then
holdthis = holdthis + 2 ^ retval
End If
Next
If holdthis = 0 Then
ordernumber.setfocus
matchthis = Trim$(ordernumber.Text)
ilong = howmany(matchthis)
If ilong > 0 Then
Set tempdb =
DBEngine.Workspaces(0).OpenDatabase(currentdatabase)
DBEngine.Workspaces(0).BeginTrans
complete.setfocus
newtext = Trim$(complete.Text)
'***PLACE I NEED TO FIX....
sqlstring = "UPDATE cardtable SET cardtable!complete=" & Chr
$(34) & newtext & Chr$(34) & " WHERE cardtable!ordernumber=" & Chr
$(34) & matchthis & Chr$(34)" AND cardtable!carddate= BETWEEN [Enter
Start Date] and [Enter End Date]";"
Set tempquerydef = tempdb.CreateQueryDef("", sqlstring)
tempquerydef.Execute
tempquerydef.Close
DBEngine.Workspaces(0).CommitTrans
tempdb.Close
Set tempdb = Nothing
End If
complete.setfocus
complete.Text = ""
ordercombo.setfocus
ordercombo.Text = ""
ordernumber.setfocus
ordernumber.Text = ""
Else
For ilong = 1 To 2
If (holdthis And (2 ^ ilong)) = 2 ^ ilong Then
Exit For
End If
Next
ctrlarray(ilong).setfocus
For ilong = 1 To 2
Set ctrlarray(ilong) = Nothing
Next
End If
End Sub
I have the following code in the database. I need to modify the SQL
string statement to also prompt for a date range based on the
"carddate". Any help would be greatly appreciated:
Private Sub changecpw_Click()
Dim ilong As Long
Dim retval As Long
Dim holdthis As Long
Dim tempquerydef As QueryDef
Dim tempdb As Database
Dim sqlstring As String
Dim matchthis As String
Dim newtext As String
Dim ctrlarray(1 To 2) As Control
retval = 0
holdthis = 0
For ilong = 1 To 2
retval = isvalid(ilong, ctrlarray())
If retval Then
holdthis = holdthis + 2 ^ retval
End If
Next
If holdthis = 0 Then
ordernumber.setfocus
matchthis = Trim$(ordernumber.Text)
ilong = howmany(matchthis)
If ilong > 0 Then
Set tempdb =
DBEngine.Workspaces(0).OpenDatabase(currentdatabase)
DBEngine.Workspaces(0).BeginTrans
complete.setfocus
newtext = Trim$(complete.Text)
'***PLACE I NEED TO FIX....
sqlstring = "UPDATE cardtable SET cardtable!complete=" & Chr
$(34) & newtext & Chr$(34) & " WHERE cardtable!ordernumber=" & Chr
$(34) & matchthis & Chr$(34)" AND cardtable!carddate= BETWEEN [Enter
Start Date] and [Enter End Date]";"
Set tempquerydef = tempdb.CreateQueryDef("", sqlstring)
tempquerydef.Execute
tempquerydef.Close
DBEngine.Workspaces(0).CommitTrans
tempdb.Close
Set tempdb = Nothing
End If
complete.setfocus
complete.Text = ""
ordercombo.setfocus
ordercombo.Text = ""
ordernumber.setfocus
ordernumber.Text = ""
Else
For ilong = 1 To 2
If (holdthis And (2 ^ ilong)) = 2 ^ ilong Then
Exit For
End If
Next
ctrlarray(ilong).setfocus
For ilong = 1 To 2
Set ctrlarray(ilong) = Nothing
Next
End If
End Sub