'Try something like this 

'----------------------ACCESS DATA BASE!----------------------------------- 
' CHANGE THE PATH BELOW TO MATCH YOUR DATABASE!!!! 
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ 
"Data Source=c:\somepath\myDb.mdb;" & _ 
"User Id=admin;" & _ 
"Password=;" 
'---------------------SQL 
SERVER-------------------------------------------------- 
'oConn.Open "Provider=SQLOLEDB.1;" & _ 
"Integrated Security=SSPI;" & _ 
"Persist Security Info=False;" & _ 
"Initial Catalog=MyDatabaseName;" & _ 
"Data Source=MyServerName;" & _ 
"Connect Timeout=120;" 


' You now have a Connection to the database.... 
' You can use this Connection to Retrieve data using SQL: 

strSQL = "SELECT * from Employee WHERE DeptID=" & cstr(iNumber) & _ 
" OR LastName = '" & sString & "' 
oRS.Open strSQL, oConn 
' You now have a Recordset (Forward Only Cursor) 
Do Until oRS.EOF 
For i = 0 To oRS.Fields.Count-1 
objWord.Selection.TypeText oRS.Fields.Item(i).Value 
objWord.Selection.TypeParagraph 
Next 
oRS.MoveNext 
Loop 
objWord.Visible=True 
oRS.Close 
oConn.Close 
ExitProc: 
On Error Resume Mext 
Set oRS = Nothing 
Set oConn = Nothing 
Exit Sub 

LookOnlyTrap: 
intInErrors = 0 
For Each errLoop In cnn1.Errors 
Debug.Print errLoop.Number, errLoop.Description 
intInErrors = intInErrors + 1 
Next errLoop 
If intInErrors = 0 Then 
Debug.Print Err.Number, Err.Description 
End If 
Resume ExitProc 

End Sub 




Another Example: 
http://www.gr-fx.com/classes/ 
NOTE you can create these classes yourself too!! 

Hope this helps... 

Oh, BTW, You CAN run Access Like The Above Automation 
Set a reference to Microsoft Access Object Library Then: 
Dim objAccess As New Access.Application 
objAccess.OpenCurrentDatabase "C:\TEST\TEST.MDB" 
' Set up Macro Called PrintSales 
objAccess.DoCmd.RunMacro "PrintSales" 









Nestor Ibarra <[EMAIL PROTECTED]> wrote:Nobody has done this before ?

Ant ideas ?

Nestor

-----Original Message-----
From: Nestor Ibarra [mailto:[EMAIL PROTECTED]
Sent: Thursday, November 11, 2004 11:43 AM
To: [EMAIL PROTECTED]
Subject: [Visual Basic 6 programming] RE: defined function in access would
not work in visual basic


I have created a vb macro to do some cost calculation in my mdb. Then I have
a query that uses this macro.

When I run the query from within access I have no problem but when I try to
run it from within my visual basic application or from Crystal report I get
an error saying that the function is undefined.

Any suggestions on how I can solve this ?
Nestor






Yahoo! Groups Links







Yahoo! Groups Sponsor 
Get unlimited calls to

U.S./Canada


---------------------------------
Yahoo! Groups Links

   To visit your group on the web, go to:
http://groups.yahoo.com/group/visualbasic6programming/
  
   To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
  
   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 




David Williams GS-11 
Air Force Engineering and Technical Services 
Misawa Air Base Japan

                        
---------------------------------
Do you Yahoo!?
 Check out the new Yahoo! Front Page. www.yahoo.com

[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/k7folB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To reply to this message, go to:
    
http://groups.yahoo.com/group/visualbasic6programming/post?act=reply&messageNum=17951
    Please do not reply to this message via email. More information here:
    http://help.yahoo.com/help/us/groups/messages/messages-23.html

<*> To visit your group on the web, go to:  
    http://groups.yahoo.com/group/visualbasic6programming/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to