How to pass a string in excel vba to access vba

svuyyuru

Registered User.
Local time
Today, 09:52
Joined
Feb 10, 2014
Messages
33
I want to pass a string aPath contains path of the active workbook to access vba module or sub. Below is my excel vba code that will open access db form. How do i pass the string value to access vba.

Code:
[/SIZE]
[SIZE=2]      Dim aPath, aDbase, aDSource, aTable, exePath As String[/SIZE][SIZE=2]  [/SIZE]
[SIZE=2]        Dim fileParam As String[/SIZE]
 [SIZE=2]       aPath [/SIZE][SIZE=2]= ActiveWorkbook.[/SIZE][SIZE=2]Path      [/SIZE]
[SIZE=2]       aDbase = "near_14.accdb"[/SIZE]
[SIZE=2]      aDSource [/SIZE][SIZE=2]= aPath & "\" &[/SIZE][SIZE=2] aDbase[/SIZE]
 
[SIZE=2]      Set appAccess = CreateObject("Access.Application")[/SIZE]
[SIZE=2]      appAccess[/SIZE][SIZE=2].Visible = True[/SIZE]
[SIZE=2]      appAccess[/SIZE][SIZE=2].[/SIZE][SIZE=2]OpenCurrentDatabase aDSource[/SIZE]
[SIZE=2]      appAccess.DoCmd.OpenForm "Import_From_P"[/SIZE]
 
[SIZE=2]      appAccess[/SIZE][SIZE=2].CloseCurrentDatabase[/SIZE]
 
You can use the OpenArgs method of the DoCmd.OpenForm method.. something like..
Code:
appAccess.DoCmd.OpenForm "Import_From_P"[COLOR=Red][B], OpenArgs:= aPath[/B][/COLOR]
 
But how do i call that in access vba
 
What? I just showed you how to, use the OpenArgs argument...
 
I'm sorry. But it says the form couldnt find or misspelled. when i add the piece of code you specifid.
 

Users who are viewing this thread

Back
Top Bottom