Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help VBA Code ?????

Status
Not open for further replies.

rjoshi2

Programmer
Sep 10, 2002
110
US
Why is my code not working. Any help would be apprecated.

Thank You,
rjoshi2

My code:

Private Sub Form_Load()
Dim strDB2 As String
Dim strTbl2 As String
'To Hide the Database Window
DoCmd.RunCommand acCmdWindowHide
myCommandBar 'create a commandbay

'strDB2 = "PSC IT Acquisition Data File"
strDB2 = "\\Psc2\Data\Ocio\SHARED\Acquisitions\Back end of PSC IT Acquisition Log\PSC IT Acquisition Data File.mdb"

strTbl2 = "Core Data Dump"

fctnRelink(strdb2, strtbl2)
End Sub

Function fctnRelink(strDB As String, strTbl As String)
DBEngine(0)(0).Execute "DROP TABLE [" & strTbl & "];"
DoCmd.TransferDatabase acLink, "Microsoft Access", strDB, acTable, strTbl, strTbl
End Function
 
Your code shouldn't compile as written because of a syntax error in this line:

fctnRelink(strdb2, strtbl2)

You don't need parentheses for the function call. If you actually use the Call statement, then you can leave them in:

Call fctnRelink(strdb2, strtbl2)

It looks like maybe you have 'Option Explicit' turned off which is a bad idea. Notice that the variables in the function call are all lower case and their corresponding declarations are 'strDB2' and 'strTbl2.'

Once you remove the parentheses the variable names will automatically correct themselves.

Nothing else seems immediately out of place.

VBSlammer
redinvader3walking.gif
 
except (possibly) if the function explicitly has a return value declared and assigned, the call should not be 'call', but have be a assignment to the return value.


MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top