X
xRoachx
I currently have five queries set up. Four of the queries
are used to gather data for the fifth query to use and
format. To simplify the process, I created a dialog box
for the four queries, for the user to select the input in
lieu of a parameter (input box). The user selects one of
the four queries to run, clicks the OK button, the query
does it's thing, thing initiates a report (based on the
5th query). The 5th query has a input parameter that I
would like to be automatically updated through VBA. I
have not been able to accomplish this. I have tried
numerous ways (see ****), two of which are in the code
below:
Private Sub cmdOK_Click()
Dim strAppType As String 'App type to determine
which query to run
Dim strTempAppType As String
Dim strClassDate As String 'Class Start Date to
pull accounts for
Dim strTempClassDate As String
'Dim dtmFormatDate As Date 'Omitted due to data
type error
Dim db As Database
Dim qd As QueryDef
'Check to ensure the user chose an app type
'and entered the class start date
'
If IsNull(cboAppTypes) Then
MsgBox "You must choose an app type." _
& vbCrLf & "Please try again.", vbExclamation,
_
"ADDITIONAL INFO REQUIRED"
cboAppTypes.SetFocus
Exit Sub
End If
If IsNull(tboClassDate) Then
MsgBox "You must enter a class date." _
& vbCrLf & "Please try again.", vbExclamation,
_
"ADDITIONAL INFO REQUIRED"
tboClassDate.SetFocus
Exit Sub
End If
'Assign default App Type
'
cboAppTypes.SetFocus
strAppType = cboAppTypes.Text
strTempAppType = """" & cboAppTypes.Text & """"
CurrentDb.TableDefs("Assignment Sheet").Fields("App
Type").DefaultValue = strTempAppType
'Assign default Class Date
'
tboClassDate.SetFocus
strClassDate = "#" & tboClassDate.Text & "#"
CurrentDb.TableDefs("Assignment Sheet").Fields("Class
Date").DefaultValue = strClassDate
'****The following code is erroring out on the
conversion****
'****Code omitted due to time constrainsts 10/6/04 -
ETrigo****
'
'dtmFormatDate = CDate(CurrentDb.TableDefs("Assignment
Sheet").Fields("Class Date").DefaultValue)
'Check for a null value in the tboClassDate field.
'If the value is null, assign it the default value
'in the Class Date field of the Assignment Sheet table.
'
' If IsNull(tboClassDate) Then
' dtmClassDate = "#" & dtmFormatDate & "#"
' Else
' tboClassDate.SetFocus
' dtmClassDate = tboClassDate.Value
' End If
'Turn off warnings for the queries
'
DoCmd.SetWarnings False
'Select the appropriate query to run
'
Select Case strAppType
Case "New App"
DoCmd.OpenQuery "New App Accts", acViewNormal,
acAdd
Case "Web App"
DoCmd.OpenQuery "Web App Accts", acViewNormal,
acReadOnly
Case "Renewal"
DoCmd.OpenQuery "Renewal Accts", acViewNormal,
acReadOnly
Case "SKIP"
DoCmd.OpenQuery "Skip App Accts", acViewNormal,
acReadOnly
Case Else
MsgBox "Please enter only New App, Web App, SKIP
App, or Renewal!", vbOKOnly + vbExclamation, "WRONG VALUE"
cboAppTypes.SetFocus
End Select
*****QUESTION STARTS HERE******
Set db = CurrentDb()
Set qd = db.QueryDefs("Assignment Sheet Query")
qd![ENTER APP TYPE] = strAppType
CurrentDb.QueryDefs("Assignment Sheet
Query").Parameters("ENTER APP TYPE").Value = strAppType
DoCmd.OpenReport "Assignment Sheet II", acViewPreview
*****QUESTION ENDS HERE******
DoCmd.Maximize
'Turn on warnings
'
DoCmd.SetWarnings True
'Close the form
'
DoCmd.Close acForm, "frmGetApplications", acSaveNo
are used to gather data for the fifth query to use and
format. To simplify the process, I created a dialog box
for the four queries, for the user to select the input in
lieu of a parameter (input box). The user selects one of
the four queries to run, clicks the OK button, the query
does it's thing, thing initiates a report (based on the
5th query). The 5th query has a input parameter that I
would like to be automatically updated through VBA. I
have not been able to accomplish this. I have tried
numerous ways (see ****), two of which are in the code
below:
Private Sub cmdOK_Click()
Dim strAppType As String 'App type to determine
which query to run
Dim strTempAppType As String
Dim strClassDate As String 'Class Start Date to
pull accounts for
Dim strTempClassDate As String
'Dim dtmFormatDate As Date 'Omitted due to data
type error
Dim db As Database
Dim qd As QueryDef
'Check to ensure the user chose an app type
'and entered the class start date
'
If IsNull(cboAppTypes) Then
MsgBox "You must choose an app type." _
& vbCrLf & "Please try again.", vbExclamation,
_
"ADDITIONAL INFO REQUIRED"
cboAppTypes.SetFocus
Exit Sub
End If
If IsNull(tboClassDate) Then
MsgBox "You must enter a class date." _
& vbCrLf & "Please try again.", vbExclamation,
_
"ADDITIONAL INFO REQUIRED"
tboClassDate.SetFocus
Exit Sub
End If
'Assign default App Type
'
cboAppTypes.SetFocus
strAppType = cboAppTypes.Text
strTempAppType = """" & cboAppTypes.Text & """"
CurrentDb.TableDefs("Assignment Sheet").Fields("App
Type").DefaultValue = strTempAppType
'Assign default Class Date
'
tboClassDate.SetFocus
strClassDate = "#" & tboClassDate.Text & "#"
CurrentDb.TableDefs("Assignment Sheet").Fields("Class
Date").DefaultValue = strClassDate
'****The following code is erroring out on the
conversion****
'****Code omitted due to time constrainsts 10/6/04 -
ETrigo****
'
'dtmFormatDate = CDate(CurrentDb.TableDefs("Assignment
Sheet").Fields("Class Date").DefaultValue)
'Check for a null value in the tboClassDate field.
'If the value is null, assign it the default value
'in the Class Date field of the Assignment Sheet table.
'
' If IsNull(tboClassDate) Then
' dtmClassDate = "#" & dtmFormatDate & "#"
' Else
' tboClassDate.SetFocus
' dtmClassDate = tboClassDate.Value
' End If
'Turn off warnings for the queries
'
DoCmd.SetWarnings False
'Select the appropriate query to run
'
Select Case strAppType
Case "New App"
DoCmd.OpenQuery "New App Accts", acViewNormal,
acAdd
Case "Web App"
DoCmd.OpenQuery "Web App Accts", acViewNormal,
acReadOnly
Case "Renewal"
DoCmd.OpenQuery "Renewal Accts", acViewNormal,
acReadOnly
Case "SKIP"
DoCmd.OpenQuery "Skip App Accts", acViewNormal,
acReadOnly
Case Else
MsgBox "Please enter only New App, Web App, SKIP
App, or Renewal!", vbOKOnly + vbExclamation, "WRONG VALUE"
cboAppTypes.SetFocus
End Select
*****QUESTION STARTS HERE******
Set db = CurrentDb()
Set qd = db.QueryDefs("Assignment Sheet Query")
qd![ENTER APP TYPE] = strAppType
CurrentDb.QueryDefs("Assignment Sheet
Query").Parameters("ENTER APP TYPE").Value = strAppType
DoCmd.OpenReport "Assignment Sheet II", acViewPreview
*****QUESTION ENDS HERE******
DoCmd.Maximize
'Turn on warnings
'
DoCmd.SetWarnings True
'Close the form
'
DoCmd.Close acForm, "frmGetApplications", acSaveNo