S
SuzyQ
Below is a snippet of code that I need help finishing. One of the fields in
my AccountNo table stores the cell location to retrieve data from an excel
spreadsheet. The data stored looks like this "Sheet1!K5" i.e. the sheet name
and cell location. I am also getting the path and name of spreadsheet and
storing it in the variable strDocName. I want to loop through a set of
records and update a specific field using the cell reference stored in
rs.ExcelCell from the spreadsheet location stored in strDocName. Can I
reference the table and cell using the data stored as mentioned? If so, what
is my statement going to look like? See code below. Thanks for all your
help.
sql = "SELECT AccountNo.FinancialReport,
AccountNo.ActivitySummaryReport, "
sql = sql & "FiscalYearBudget.[Acct No], FiscalYearBudget.FiscalYear, "
sql = sql & "FiscalYearBudget.ActualBudgetAmt, AccountNo.ExcelCell "
sql = sql & "FROM AccountNo INNER JOIN FiscalYearBudget ON "
sql = sql & "AccountNo.[Acct No] = FiscalYearBudget.[Acct No] "
sql = sql & "WHERE AccountNo.FinancialReport = True And "
sql = sql & "AccountNo.ActivitySummaryReport = False And "
sql = sql & "FiscalYearBudget.FiscalYear = " & Me.cmbFiscalYear
'update from spreadsheet
Set rs = CurrentDb.OpenRecordset(sql)
'stDocName = the path and file name of the spreadsheet
Do While Not rs.EOF
sql = "UPDATE FiscalYearBudget "
sql = sql & "SET FiscalYearBudget.ActualBudgetAmt = " & "I NEED HELP
WITH THIS CODE RIGHT HERE"
sql = sql & "WHERE FiscalYearBudget.[Acct No]= " & rs![Acct No]
sql = sql & "AND FiscalYearBudget.FiscalYear)= " & Me.cmbFiscalYear
If Not rs.EOF Then
rs.MoveNext
End If
Loop
my AccountNo table stores the cell location to retrieve data from an excel
spreadsheet. The data stored looks like this "Sheet1!K5" i.e. the sheet name
and cell location. I am also getting the path and name of spreadsheet and
storing it in the variable strDocName. I want to loop through a set of
records and update a specific field using the cell reference stored in
rs.ExcelCell from the spreadsheet location stored in strDocName. Can I
reference the table and cell using the data stored as mentioned? If so, what
is my statement going to look like? See code below. Thanks for all your
help.
sql = "SELECT AccountNo.FinancialReport,
AccountNo.ActivitySummaryReport, "
sql = sql & "FiscalYearBudget.[Acct No], FiscalYearBudget.FiscalYear, "
sql = sql & "FiscalYearBudget.ActualBudgetAmt, AccountNo.ExcelCell "
sql = sql & "FROM AccountNo INNER JOIN FiscalYearBudget ON "
sql = sql & "AccountNo.[Acct No] = FiscalYearBudget.[Acct No] "
sql = sql & "WHERE AccountNo.FinancialReport = True And "
sql = sql & "AccountNo.ActivitySummaryReport = False And "
sql = sql & "FiscalYearBudget.FiscalYear = " & Me.cmbFiscalYear
'update from spreadsheet
Set rs = CurrentDb.OpenRecordset(sql)
'stDocName = the path and file name of the spreadsheet
Do While Not rs.EOF
sql = "UPDATE FiscalYearBudget "
sql = sql & "SET FiscalYearBudget.ActualBudgetAmt = " & "I NEED HELP
WITH THIS CODE RIGHT HERE"
sql = sql & "WHERE FiscalYearBudget.[Acct No]= " & rs![Acct No]
sql = sql & "AND FiscalYearBudget.FiscalYear)= " & Me.cmbFiscalYear
If Not rs.EOF Then
rs.MoveNext
End If
Loop