Reading Excel Checkboxes in Access

R

Risky_Business

Hi All
I created a spreadsheet with checkboxes (controls) on it for reporting
purposes. I now need to import the data contained on the spreadsheets
into Access. The data is not laid out in neat columns or rows, it was
formated to be a stand alone report originally. My problem is not in
reading cells within the spreadsheet, I'm able to do that. My issue
is that I can't tell if a checkbox is checked or not.

What I've done:

If I execute the following code in Excel I return a boolean
partAM = CheckBox15.Value
I return true or false

Here is my access code:
Set xlapp = New Excel.Application

Set xlwb = xlapp.Workbooks.Open(f)


Set xlws = xlwb.Sheets("sheet1")

dte = Cells(4, 4)
adt = Cells(6, 4)
cse = Left(Cells(8, 4), 7)
cert = Mid(Cells(8, 4), 8, 4)
lname = Trim(Cells(10, 4))
fname = Trim(Cells(12, 4))
partAM = CheckBox15.Value


xlwb.Close
Set xlapp = Nothing

Set xlwb = Nothing
Set xlws = Nothing


Why does this code work in Excel but not Access???


Thanks a ton in advance
 
B

Brendan Reynolds

Risky_Business said:
Hi All
I created a spreadsheet with checkboxes (controls) on it for reporting
purposes. I now need to import the data contained on the spreadsheets
into Access. The data is not laid out in neat columns or rows, it was
formated to be a stand alone report originally. My problem is not in
reading cells within the spreadsheet, I'm able to do that. My issue
is that I can't tell if a checkbox is checked or not.

What I've done:

If I execute the following code in Excel I return a boolean
partAM = CheckBox15.Value
I return true or false

Here is my access code:
Set xlapp = New Excel.Application

Set xlwb = xlapp.Workbooks.Open(f)


Set xlws = xlwb.Sheets("sheet1")

dte = Cells(4, 4)
adt = Cells(6, 4)
cse = Left(Cells(8, 4), 7)
cert = Mid(Cells(8, 4), 8, 4)
lname = Trim(Cells(10, 4))
fname = Trim(Cells(12, 4))
partAM = CheckBox15.Value


xlwb.Close
Set xlapp = Nothing

Set xlwb = Nothing
Set xlws = Nothing


Why does this code work in Excel but not Access???


Thanks a ton in advance


Well I'm guessing, because you haven't told us what happens when you try to
execute this code in Access, but my first guess would be that you probably
need to qualify the references to members of the Sheet object by specifying
their parent object, e.g. something like "dte = xlws.Cells(4.4)" rather than
just "dte = Cells(4,4)".
 
R

Risky_Business

the dte = Cells(4,4) part of the code is working fine. My issue is
trying to read the Checkbox. I tried refering to the the worksheet
e.g. partAM = xlb.xls.CheckBox15.Value and my variable was still
empty. I've checked Excel9 Referance, is there a control referance
that I need to check too?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top