A
amg0657
Hello,
I'm new to VBA Access. I have 2 databases that have the same information.
One db is a staging db and the other db is production. I created a form in
the staging db and it successfully executes everything I want it to do.
However, when I copy the form to production, I get a compile error,
"User-defined type not defined". When I try to execute the form in
production, the first variable declaration "wb As Workbook" is highlighted.
Here is the first part of the code:
*************************************************
Public Sub Command0_Click()
Dim wb As Workbook
Dim ws As Worksheet
Dim db As DAO.Database
Set wb = Workbooks.Open("R:\Adrian\YTD DB\Weekly Open Positions
Report_Current.xls")
Set db = CurrentDb
'Deletes the previous table that exists
DoCmd.DeleteObject acTable, "Details"
strWbName = "R:\Adrian\YTD DB\Weekly Open Positions Report_Current.xls"
For Each ws In wb.Worksheets
If InStr(ws.Name, "Details") Then
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9,
ws.Name, _
strWbName, True, ws.Name & "$"
End If
Next ws
***************************************************
Is this a problem that can be easily solved? I've gone to Tools/Options and
selected "Require Variable Declaration" but I still get the compile error.
Please advise. Thanks.
AMG
I'm new to VBA Access. I have 2 databases that have the same information.
One db is a staging db and the other db is production. I created a form in
the staging db and it successfully executes everything I want it to do.
However, when I copy the form to production, I get a compile error,
"User-defined type not defined". When I try to execute the form in
production, the first variable declaration "wb As Workbook" is highlighted.
Here is the first part of the code:
*************************************************
Public Sub Command0_Click()
Dim wb As Workbook
Dim ws As Worksheet
Dim db As DAO.Database
Set wb = Workbooks.Open("R:\Adrian\YTD DB\Weekly Open Positions
Report_Current.xls")
Set db = CurrentDb
'Deletes the previous table that exists
DoCmd.DeleteObject acTable, "Details"
strWbName = "R:\Adrian\YTD DB\Weekly Open Positions Report_Current.xls"
For Each ws In wb.Worksheets
If InStr(ws.Name, "Details") Then
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9,
ws.Name, _
strWbName, True, ws.Name & "$"
End If
Next ws
***************************************************
Is this a problem that can be easily solved? I've gone to Tools/Options and
selected "Require Variable Declaration" but I still get the compile error.
Please advise. Thanks.
AMG