Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default openning Access via Excel

hi all,

can you please correct my codes or any other setting for my Excel program?
I got this error "Complie error, User-defined type not defined", codes below
in Modules:

Public Sub iConn()
Set oaccess = New Access.Application
oaccess.OpenCurrentDatabase (Sheets("Main").Range("A1").Value)
Set db = oaccess.CurrentDb()
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default openning Access via Excel

Check to see if you have set up a reference to Access.

In VBA, select Tools/References and ensure Access is checked (probably will
be listed as Microsoft Access).



"Huaqin" wrote:

hi all,

can you please correct my codes or any other setting for my Excel program?
I got this error "Complie error, User-defined type not defined", codes below
in Modules:

Public Sub iConn()
Set oaccess = New Access.Application
oaccess.OpenCurrentDatabase (Sheets("Main").Range("A1").Value)
Set db = oaccess.CurrentDb()
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default openning Access via Excel

Thanks JMB, that worked. I have another error while the following codes,
"run-time error 424, object required", please help again if you have the
chance.

I try to input excel data into access db.....


Sub Add_Click()

Dim criteria As String
iConn
Set db = oaccess.CurrentDb()
Set rs = db.OpenRecordset("Customer_tbl", dbOpenDynaset)
If Cells(6, "C") < "" Then
criteria = "Customer_ID = '" & Cells(6, "C") & "'"
rs.FindFirst UCase(criteria)
If Not rs.NoMatch Then
MsgBox "Customer code is in the database already, please use
other."
rs.Close
db.Close
Exit Sub
Else
rs.AddNew
End If
rs!Customer_ID = UCase(Cells(6, "C"))
rs!Customer_Full_Name = UCase(Cells(7, "C"))
rs!Address = Cells(8, "C")
rs!City = Cells(9, "C")
rs!State = Cells(10, "C")
rs!Telephone = Cells(11, "C")
rs!Note = Cells(12, "C")
rs.Update
MsgBox "Record update."
Else
MsgBox "Please input Customer code and Full Name."
rs.Close
db.Close
Exit Sub
End If

rs.Close
db.Close

End Sub





"JMB" wrote:

Check to see if you have set up a reference to Access.

In VBA, select Tools/References and ensure Access is checked (probably will
be listed as Microsoft Access).



"Huaqin" wrote:

hi all,

can you please correct my codes or any other setting for my Excel program?
I got this error "Complie error, User-defined type not defined", codes below
in Modules:

Public Sub iConn()
Set oaccess = New Access.Application
oaccess.OpenCurrentDatabase (Sheets("Main").Range("A1").Value)
Set db = oaccess.CurrentDb()
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default openning Access via Excel

Unfortunately, I have limited experience w/Access (I don't own Access - so
cannot set up a test to try to duplicate your problem).

I assume oaccess is declared as a public variable.

Does Excel highlight a specific line?


"Huaqin" wrote:

Thanks JMB, that worked. I have another error while the following codes,
"run-time error 424, object required", please help again if you have the
chance.

I try to input excel data into access db.....


Sub Add_Click()

Dim criteria As String
iConn
Set db = oaccess.CurrentDb()
Set rs = db.OpenRecordset("Customer_tbl", dbOpenDynaset)
If Cells(6, "C") < "" Then
criteria = "Customer_ID = '" & Cells(6, "C") & "'"
rs.FindFirst UCase(criteria)
If Not rs.NoMatch Then
MsgBox "Customer code is in the database already, please use
other."
rs.Close
db.Close
Exit Sub
Else
rs.AddNew
End If
rs!Customer_ID = UCase(Cells(6, "C"))
rs!Customer_Full_Name = UCase(Cells(7, "C"))
rs!Address = Cells(8, "C")
rs!City = Cells(9, "C")
rs!State = Cells(10, "C")
rs!Telephone = Cells(11, "C")
rs!Note = Cells(12, "C")
rs.Update
MsgBox "Record update."
Else
MsgBox "Please input Customer code and Full Name."
rs.Close
db.Close
Exit Sub
End If

rs.Close
db.Close

End Sub





"JMB" wrote:

Check to see if you have set up a reference to Access.

In VBA, select Tools/References and ensure Access is checked (probably will
be listed as Microsoft Access).



"Huaqin" wrote:

hi all,

can you please correct my codes or any other setting for my Excel program?
I got this error "Complie error, User-defined type not defined", codes below
in Modules:

Public Sub iConn()
Set oaccess = New Access.Application
oaccess.OpenCurrentDatabase (Sheets("Main").Range("A1").Value)
Set db = oaccess.CurrentDb()
End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Openning spesific file in Excel Farhad Excel Discussion (Misc queries) 1 November 29th 07 02:11 PM
Openning Excel Files takes too long rook Excel Discussion (Misc queries) 1 April 24th 06 10:05 PM
Openning Excel by double clicking on the file name in Explorer Joseph Excel Discussion (Misc queries) 2 July 1st 05 04:17 PM
How to start a macro when openning Excel pinguino2005 Excel Programming 4 May 30th 05 01:28 AM
Getting dw20.exe error while openning excel formatted xml file Anjan Excel Programming 0 October 4th 04 02:21 PM


All times are GMT +1. The time now is 01:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"