Parameter Query not working

M

Michael

Hi
I'm having a slight problem with some code that I have. I'm using Access
2003 and have an attached database with the same exact table layout that I'm
importing to. The problem is that I have 10 parameterized querys and only one
of them works with the code I have:
Private Function WriteData(QueryName As String, PatientId As Long,
NewPatientId As Long) As Boolean
Dim mCommand As ADODB.Command
Dim Param As ADODB.Parameter
Dim Param2 As ADODB.Parameter
On Error GoTo Err_WriteDate
Set mCommand = New ADODB.Command
mCommand.CommandType = adCmdUnknown
mCommand.ActiveConnection = Application.CurrentProject.Connection
mCommand.CommandText = QueryName
Set Param = mCommand.CreateParameter("[PatientId]", adNumeric,
adParamInput)
mCommand.Parameters.Append Param
mCommand.Parameters("[PatientId]").Value = PatientId
If NewPatientId <> 0 Then
Set Param2 = mCommand.CreateParameter("[NewPatientId]", adNumeric,
adParamInput)
mCommand.Parameters.Append Param2
mCommand.Parameters("[NewPatientId]").Value = NewPatientId
End If
mCommand.Execute
Set mCommand = Nothing
Set Param = Nothing
Set Param2 = Nothing
Exit Function
Err_WriteDate:
MsgBox Err.Description
End Function

The first query that is used works fine (it takes only one parameter), but
all other calls to this function does not insert the data into the table. If
I take the same values and run the query manually, the query does insert the
records. But if I run the code it don't work. Also there are NO ERRORS when
this happens, so I assume it took it. Here is a sample query:
INSERT INTO Identification1 ( PatientIDCount, Birth_Certificate,
Social_Security_Card, Other_Card, PictureID_Card, Payment_Method,
Medicaid_Number, Other_Pay_Comment )
SELECT [NewPatientId], Identification.Birth_Certificate,
Identification.Social_Security_Card, Identification.Other_Card,
Identification.PictureID_Card, Identification.Payment_Method,
Identification.Medicaid_Number, Identification.Other_Pay_Comment
FROM Identification
WHERE Identification.PatientIdCount = [PatientId];

Thanks for any info and help.
Michael Lee
 

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