Hi All,
I am trying to Accomplish the following:
I am trying to Accomplish the following:
- Create a form that has a search function to search an item list but allow the user to also search through the item list using a bar to move up and down through the list.
- allow the user to edit only 1 column in the list (qty)
- list is stored in a table named "tblWireRack"
- in a command button, ******* event I would like the command button to run a modual:I am currently using a Macro to accomplish this (openvisualbasicsmodual >Modual Name: "Module1" > Procedure Name: "sCopyRSToNamedRange") [This is only opening the Modual. I need a command to run the modual]
- The Modual is giving me a Compile error User-defined type not defined on VBA line Set objXL = New Excel.Application in the following Code:
Code:
[/FONT][FONT=arial]Sub sCopyRSToNamedRange()'Copy records to a named range 'on an existing worksheet on a 'workbook ' 'Dim objXL As Excel.Application Dim objXL As Object Set objXL = CreateObject("Excel.Application") 'Dim objWkb As Excel.Workbook Dim objWkb As Object Set objWkb = CreateObject("Excel.Workbook") 'Dim objSht As Excel.Worksheet Dim objSht As Object Set objSht = CreateObject("Excel.Worksheet") Dim db As Database Dim rs As Recordset Const conMAX_ROWS = 20000 Const conSHT_NAME = "MySheet" Const conWKB_NAME = "c:\temp\Test1.xls" Const conRANGE = "RangeForRS" Set db = CurrentDb Set objXL = New Excel.Application Set rs = db.OpenRecordset(tblWireRack, dbWebADIItemManagment) With objXL .Visible = True Set objWkb = .Workbooks.Open(conWKB_NAME) On Error Resume Next Set objSht = objWkb.Worksheets(conSHT_NAME) If Not Err.Number = 0 Then Set objSht = objWkb.Worksheets.Add objSht.Name = conSHT_NAME End If Err.Clear On Error GoTo 0 objSht.Range(conRANGE).CopyFromRecordset rs End With Set objSht = Nothing Set objWkb = Nothing Set objXL = Nothing Set rs = Nothing Set db = Nothing End Sub
The primary issue right now is the Compile error. If you have any advice on any of the other needs please share.
Thank you!!