i don't quite follow what you've done here.
I 3 3 buttons on my form, 1 imports data & cleans it up, 2 prints out reports and 3 exports the data. so i want sub on button 3 to access variables set by button 2.
Here is my code (the 2 starred lines in button 3 are the lines that i want to be able to reference what button 1 set.
This is button 1 code,
Private Sub Command5_Click()
Dim filename As String, filepath As String
Dim msg_folder_notexist As String
Dim import_check_response As String, import_check_style As String, import_check_msg As String, import_check_title As String
Dim bad_import_msg As String, bad_import_title As String, bad_import_style As String
bad_import_msg = "Please contact Jamie x2038 immediately"
bad_import_title = "Import failed"
bad_import_style = vbOKOnly + vbApplicationModal + vbCritical
import_check_msg = "Does this look OK?"
import_check_title = "Data import check"
import_check_style = vbYesNo + vbQuestion + vbApplicationModal
filepath = "\\capt_kirk\conversion\data\caa"
filename = GetTheOldestFile(filepath, "*.txt")
Set fs = CreateObject("Scripting.FileSystemObject")
msg_folder_notexist = "The folder " & filepath & " does not exist Please contact Jamie on x2038"
If fs.FolderExists(filepath) Then
If filename = "" Then
MsgBox prompt:="There are no more files to Import"
Else
DoCmd.TransferText acImportFixed, "Import", "tblImport_Data", filename
DoCmd.OpenQuery "qryExport_Data"
import_check_response = MsgBox(import_check_msg, import_check_style, import_check_title)
If import_check_response = vbYes Then
DoCmd.Close acQuery, "qryExport_data", acSaveNo
Else
import_check_response = MsgBox(bad_import_msg, bad_import_style, bad_import_title)
End If
End If
Else
MsgBox prompt:=msg_folder_notexist
End If
End Sub
this is button 3 code,
Private Sub Command6_Click()
Dim filepath As String, filename As String
Dim exportfilepath As String
*filepath = "\\capt_kirk\conversion\data\caa"
*filename = GetTheOldestFile(filepath, "*.txt")
Set fs = CreateObject("Scripting.FileSystemObject")
exportfilepath = filepath & "\done\"
exportpath_notexist_msg = "The export path doesn't exist. Please contact Jamie x2038 immediately"
exportpath_notexist_title = "Error"
exportpath_notexist_style = vbOKOnly + vbApplicationModal + vbCritical
If fs.FolderExists(exportfilepath) Then
fs.MoveFile filename, exportfilepath
MsgBox prompt:="File exported"
Else
MsgBox exportpath_notexist_msg, exportpath_notexist_style
End If
End Sub