Terri Hdokins
Registered User.
- Local time
- Today, 00:19
- Joined
- Jun 21, 2001
- Messages
- 15
Re: If... Then... Statement
I am a little stuck right and came seem to get my VBA code to work. Let me see if I can explain.
I have a master table called "tblWeeks" which contains all sales information by weeks. Then I have a temp table called "tblTemp" in which I use to bring in my week working on. I then created a unmatched query that I want to use to see if I have already brought in a week. In my VBA basic I am trying to say that if the value is "", then msgbox.... Else go ahead and do the append query.
Here is my code that I have so far. I really hope someone can help me.
Thanks in advance,
Terri Hodkins
Private Sub cmdImportPlWk_Click()
On Error GoTo cmdImportPlWk_Err
DoCmd.Echo True, ""
DoCmd.OpenTable "tblTemp", acNormal, acEdit
DoCmd.RunMacro "macDelete", , ""
DoCmd.TransferSpreadsheet acImport, 8, "tblTemp", "U:\DATAFILE\Fresh Kist Produce\DATABASE\MASTER POOL WEEK", _
True, "tblWeeks!A1:I9999"
DoCmd.Close acTable, "tblTemp"
DoCmd.OpenQuery "qryUnmatchedPoWk", acViewNormal, acEdit
If IsNull(Query![qryUnmatchedPoWk]![PoWk]) Then
msgbox ("***** YOU HAVE ALREADY IMPORTED THIS POOL WEEK *****")
DoCmd.Close acQuery, "qryUnmatchedPoWk"
Else:
DoCmd.Close acQuery, "qryUnmatchedPoWk"
DoCmd.RunMacro "macAppendPoWk", , ""
Beep
msgbox "***** IMPORT OF POOL WEEK IS COMPLETE *****", vbInformation, ""
End If
Exit Sub
I am a little stuck right and came seem to get my VBA code to work. Let me see if I can explain.
I have a master table called "tblWeeks" which contains all sales information by weeks. Then I have a temp table called "tblTemp" in which I use to bring in my week working on. I then created a unmatched query that I want to use to see if I have already brought in a week. In my VBA basic I am trying to say that if the value is "", then msgbox.... Else go ahead and do the append query.
Here is my code that I have so far. I really hope someone can help me.
Thanks in advance,
Terri Hodkins
Private Sub cmdImportPlWk_Click()
On Error GoTo cmdImportPlWk_Err
DoCmd.Echo True, ""
DoCmd.OpenTable "tblTemp", acNormal, acEdit
DoCmd.RunMacro "macDelete", , ""
DoCmd.TransferSpreadsheet acImport, 8, "tblTemp", "U:\DATAFILE\Fresh Kist Produce\DATABASE\MASTER POOL WEEK", _
True, "tblWeeks!A1:I9999"
DoCmd.Close acTable, "tblTemp"
DoCmd.OpenQuery "qryUnmatchedPoWk", acViewNormal, acEdit
If IsNull(Query![qryUnmatchedPoWk]![PoWk]) Then
msgbox ("***** YOU HAVE ALREADY IMPORTED THIS POOL WEEK *****")
DoCmd.Close acQuery, "qryUnmatchedPoWk"
Else:
DoCmd.Close acQuery, "qryUnmatchedPoWk"
DoCmd.RunMacro "macAppendPoWk", , ""
Beep
msgbox "***** IMPORT OF POOL WEEK IS COMPLETE *****", vbInformation, ""
End If
Exit Sub