Append Query And Function

A

a

Thank you

Dear All

I create append query to add record to ((((((((Another Database))))))))):

Access problem:

You Should in Append Query determine the Location of Your data base
((((Another Data base))) You want to add record to it.

What I have:

I have this function:

Public Function fCurrentDBDir() As String

'code courtesy of

'Terry Kreft

Dim strDBPath As String

Dim strDBFile As String

strDBPath = CurrentDb.Name

strDBFile = Dir(strDBPath)

fCurrentDBDir = Left(strDBPath, InStr(strDBPath, strDBFile) - 1) &"db1"

End Function

What is the job of this function:

Give me the path of the data base that I want add record to (((((Another
Data base)))))))



What I want:

I want to use this function in append query to pass the value of the
function to the append query

How can I do that:



I have try many option but I can't reach the answer:



This is My SQl



INSERT INTO tblapp( firstname ) IN 'C:\db1.mdb' SELECT
Tblplayer.Nameofplayer FROM Tblplayer;



What I do: I put the function in the append query like this:

Docmd.RunSQl "INSERT INTO tblapp( firstname ) IN fCurrentDBDir SELECT
Tblplayer.Nameofplayer FROM Tblplayer;"



This error appear to me:

Run-time error '3024"

Could not find file 'C:\FcurrentDBDir'



I do this also

Dim mysql As String

mysql = "INSERT INTO tblapp (firstname) IN"

mysql = mysql & fCurrentDBDir

mysql = mysql & "SELECT Tblplayer. Nameofplayer "

mysql = mysql & "FROM Tblplayer;"

DoCmd.RunSQL mysql



Run-time error '3134'

Syntax error in INSERT INTO STATEMENT



What should I do

Is this possible
 
M

mcescher

Thank you

Dear All

I create append query to add record to ((((((((Another Database))))))))):

Access problem:

You Should in Append Query determine the Location of Your data base
((((Another Data base))) You want to add record to it.

What I have:

I have this function:

Public Function fCurrentDBDir() As String

'code courtesy of

'Terry Kreft

Dim strDBPath As String

Dim strDBFile As String

    strDBPath = CurrentDb.Name

    strDBFile = Dir(strDBPath)

    fCurrentDBDir = Left(strDBPath, InStr(strDBPath, strDBFile) - 1)&"db1"

End Function

What is the job of this function:

Give me the path of the data base that I want add record to (((((Another
Data base)))))))

What I want:

I want to use this function in append query to pass the value of the
function to the append query

How can I do that:

I have try many option but I can't reach the answer:

This is My SQl

INSERT INTO tblapp( firstname ) IN 'C:\db1.mdb' SELECT
Tblplayer.Nameofplayer FROM Tblplayer;

What I do: I put the function in the append query like this:

Docmd.RunSQl "INSERT INTO tblapp( firstname ) IN fCurrentDBDir SELECT
Tblplayer.Nameofplayer FROM Tblplayer;"

This error appear to me:

Run-time error '3024"

Could not find file 'C:\FcurrentDBDir'

I do this also

Dim mysql As String

mysql = "INSERT INTO tblapp (firstname) IN"

mysql = mysql & fCurrentDBDir

mysql = mysql & "SELECT Tblplayer. Nameofplayer "

mysql = mysql & "FROM Tblplayer;"

DoCmd.RunSQL mysql

Run-time error '3134'

Syntax error in INSERT INTO STATEMENT

What should I do

Is this possible

If you're wanting to append records to another Access db, then I would
suggest linking the table from the other database into your source
db. Then you could run a standard append query on it.

Hope this helps,
Chris M.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top