I guess I don't understand the public variable piece.
I don't care how I set the variable 'intstartrow' the easier the better. It will be either 1 2 or 3 depending on which spreadsheet is being imported. since each spreadsheet has its own import button I think this is the place to set it but I cant get the module to use the number.
Here is all the beginning code to where the call is made in the module.
And more of the button action code if you can show me were to dim the variable and how to call it in the module it would be great.
As you can tell by the question I am a novice just trying to fix this!
----module code----
Public Function ProcessFileImport(ByVal sFile As String, ByVal sTable As String) As String
On Error GoTo ProcessFileImport_Error
' Excel object variables
Dim appexcel As Excel.Application
Dim wbk As Excel.Workbook
Dim wks As Excel.Worksheet
' Access object variables
Dim dbs As DAO.Database
Dim rstRead As DAO.Recordset
Dim rstWrite As DAO.Recordset
Dim fld As DAO.Field
' Declared variables
Dim bytWks As Byte
Dim bytMaxPages As Byte
Dim intStartRow As Integer
Dim strData As String
Dim intMaxRow As Integer
Dim strSQL As String
Dim strMsg As String
Dim intLastCol As Integer
Dim intRow As Integer
Dim intRec As Integer
Dim strCurrFld As String
Dim intCol As Integer
Dim intLen As Integer
Dim varValue As Variant
Dim lngErrs As Long
Const cPassword As String = "xxx999"
DoCmd.Hourglass True
' Create the Excel Applicaiton, Workbook and Worksheet and Database object
Set appexcel = Excel.Application
Set wbk = appexcel.Workbooks.Open(sFile)
Set dbs = CurrentDb
' Optionally, you can protect / unprotect with a password
'wkb.Unprotect (cPassword)
' You could loop through sheets, but for this example, we'll just do one.
bytMaxPages = 1
' Sometimes there is header info, so the "Start Row" isn't the first one.
' Set this variable to the first row that contains actual data.
intStartRow = "this is where i need the number from the import button"
--------
Private Sub cmdImport_Click()
On Error Resume Next
Dim strMsg As String
Dim strFile As String
Dim xcomp As String
xcomp = " "
Dim strFilter As String
Dim strInputFileName As String
"Here is where i was trying to set the value"
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
Me.txtFile = strInputFileName
strFile = Nz(Me.txtFile, "")
------
CR