The following code attempts to create an append to table called [PA1link] and append the data to a table called [Customers] in the DB called [ProReport1]. As the location of [ProReport1] may vary due to the installation on a variety of servers its location is dictated by the [Links] table which is accessed via a dlookup.
All works OK, that is the Append Table is produced with the correct data but it isn't added to the destination database. No error messages are produced.
If I run the resultant query via the query window the append works. It almost looks like the code is missing a "run" command of some sort but I am under the impression that the "Insert Into" does that job. Any thoughts would be appreciated. Thankyou
All works OK, that is the Append Table is produced with the correct data but it isn't added to the destination database. No error messages are produced.
If I run the resultant query via the query window the append works. It almost looks like the code is missing a "run" command of some sort but I am under the impression that the "Insert Into" does that job. Any thoughts would be appreciated. Thankyou
Code:
Private Sub PAManagementBtn_Click()
On Error GoTo Err_PAManagementBtn_Click
'If MsgBox("You are about to add a new client to the Progress Reporter Program." & vbCrLf & "Do not do this if you have already done it before for this client." & _
'" If the Client already has had a Report set up make sure that the [Client Now On Program] field is completed. Then open Progress Reporter from Quicklinks." & Chr(13) & "Do you still wish to add the Client?", vbOKCancel, "Progress Reporter") = vbOK Then
'DoCmd.SetWarnings False
Dim qdf As QueryDef
Dim strsql As String
Dim ServerPath As Variant
ServerPath = DLookup("[Link]", "links", "[linkname] = 'PAActivity'")
If IsNull(varserver) Then
MsgBox ("Unknown Path.")
Else
strsql = "INSERT INTO Customers (Advisor, ClientID, C1surname, " & _
" C1firstname, C2Surname, C2firstname, " & _
" stNo, StName, Locality, postcode) " & _
"IN '" & ServerPath & "' " & _
"SELECT advisors, ClientNo, Client1Name1, Client1Name2, Client2Name1, Client2Name2, StreetNo, StreetName, Locality, Postcode " & _
"FROM [Client action]" & _
"WHERE [Client action].ClientNo = " & [Forms]![client action amended]![ClientNo] & ";"
Set qdf = CurrentDb.CreateQueryDef("PA1Link")
qdf.sql = strsql
qdf.Close
'DoCmd.DeleteObject acQuery, "PA1Link"
End If
'DoCmd.SetWarnings True
Application.FollowHyperlink DLookup("[Link]", "links", "[linkname] = 'PAActivity'")
' Else: Exit Sub
' End If
Exit_PAManagementBtn_Click:
Exit Sub
Err_PAManagementBtn_Click:
MsgBox Err.Description
Resume Exit_PAManagementBtn_Click
End Sub
Last edited: