I am reposting this from another forum, my apologies. I am using access 2003. I have a string of queries that I want to run in sequence. Some of the queries have variables that need to go into them. I have figured out how to calculate the variables but I don't know how to pass tha variables into the queries. I am trying to pass the string strCurMon into .OpenQuery "001_PostPmtsToTemp" . I am trying to pass strCurMonName into .OpenQuery "102_PostChgAmt. Any help would be appreaciated.
'Current Period
strCurMonName = MonShortName(CurMon)
'Current Month
strCurMon = Right(strCurMonName, 2)
'Current Period
strCurMonName = MonShortName(CurMon)
'Current Month
strCurMon = Right(strCurMonName, 2)
Code:
Private Sub cmdImport_Click()
Dim strUCI As String
Dim strFileCS As String
Dim strFileAR As String
Dim strFileFullAR As String
Dim liFileMonth As String
Dim strFileMonth As String
Dim strClose As String
Dim strDictUpdt As String
Dim intCurMon As Integer
Dim strCurMon As String
Dim strCurMonName As String
DoCmd.SetWarnings False
Me.txtUCI.SetFocus
strUCI = Me.txtUCI.Text
'On Error GoTo IMP_ERR
If Not IsNull(Me.cboImpMonData.Value) Then
'Me!cboImpMonData.Column (1)
liFileMonth = Me.cboImpMonData.Value
strFileMonth = Me.cboImpMonData.Column(1)
'Current Period
strCurMonName = MonShortName(CurMon)
'Current Month
strCurMon = Right(strCurMonName, 2)
' IMPORT FILE & RUN FIXES
With DoCmd
.OpenQuery "000_ClearCalcPmts"
.OpenQuery "000_ClearPatients"
.OpenQuery "000_ClearTempMarkBilled"
.OpenQuery "001_PostPmtsToTemp" ' enter month
.OpenQuery "002_PostAggregatePmts"
.OpenQuery "102_PostChgAmt" 'enter period
.OpenQuery "103_SetChgAmt"
.OpenQuery "104_PostPatients"
.OpenQuery "105_ClearMarkBilled"
.OpenQuery "106_PostBilled"
.OpenQuery "107_MarkBilled"
End With
strClose = "UPDATE DICT_ImportMonthList SET finalpost=1 WHERE (ID=" & (liFileMonth) & ");"
CurrentDb.Execute strClose
With Me.cboRptMon
.SetFocus
.Requery
End With
' DONE
MsgBox "SUCCESSFUL IMPORT!", , "WHOO!"
Else
MsgBox "Please select a month for import.", , "ERROR"
End If
DoCmd.SetWarnings True
Exit Sub
IMP_ERR:
DoCmd.SetWarnings True
MsgBox "File Not Found.", , "ERROR"
Exit Sub
End Sub