My problem is that i have to copy some Optionbuttons from an Excel document to Access.
But there is coming an Error 438? The Erros is Coming
Error 438? The Erros is Coming
oWS.Worksheets("Tabelle1").Controls("OptionButton" & i).Value` on this part of the code.
When i write the code like this it works.
".Fields("id") = oWS.Worksheets("Tabelle1").OptionButton4.Value"
But i Have a lot of Optioinbuttons because of that i want to make a "for loop".
I have Access 2013.
This is the code:
Set oWS = oXL.Workbooks.Open(strPath & strFile)
Set rs = CurrentDb.OpenRecordset("test")
With rs
'i = 14
For i = 3 To 10
.AddNew
.Fields("id") = oWS.Worksheets("Tabelle1").Controls("OptionButton" & i).Value
.Update
Next i
.Close
End With
Sheets don't have a Controls-Collection, but an OLEObjects-Collection where you can find the OptionButtons. Try:
.Fields("id") = oWS.Worksheets("Tabelle1").OLEObjects("OptionButton" & i).Object.Value
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.