Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help on passing strings and variables into queries

Status
Not open for further replies.

vba317

Programmer
Mar 5, 2009
708
US
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)

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)
          
    ' Get Closed Option and Set File
    strFileCS = "\\salmfilesvr1\public\Client Services\Automate\Dnlds\" & (strUCI) & "\" & (strUCI) & "_CS_Data_" & (strFileMonth) & ".txt"
    strFileAR = "\\salmfilesvr1\public\Client Services\Automate\Dnlds\" & (strUCI) & "\" & (strUCI) & "_AR_Data_" & (strFileMonth) & ".txt"
    strFileFullAR = "\\Server\E\Balout\" & (strUCI) & "_AR_Data_" & (strFileMonth) & ".txt"
    ' 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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top