B
bigbore50
I want to open table and check to see if PDN exsists in that table
If PDN is in the table i would like to update that Record with some
txt boxes
If PDN is not in the table i want it to insert a New record
It sounds simple but i think i am doind something wrong
Here is the code... What is wrong with it?
Set rstedit = db.OpenRecordset("SELECT * FROM tblDocumentList WHERE
[num] = " & searchcrit)
If rstedit.RecordCount = 1 Then
QrySQL = "UPDATE [tblAlternateDealerInfo] "
Set tblAlternateDealerInfo.BC = " & Me.txtBC & ",
tblAlternateDealerInfo.PDN = " & Me.TxtPDN & ",
tblAlternateDealerInfo.WSN = " & Me.TxtWSN & ",
tblAlternateDealerInfo.Name = " & Me.TxtNAme & ",
tblAlternateDealerInfo.Address = " & Me.TxtAddress & ",
tblAlternateDealerInfo.City = " & Me.TxtCity & ",
tblAlternateDealerInfo.State = " & Me.TxtState & ",
tblAlternateDealerInfo.Zip = " & Me.TxtZip & ",
tblAlternateDealerInfo.Phone = " & Me.TxtPhone & ",
tblAlternateDealerInfo.Fax = " & Me.TxtFax & ",
tblAlternateDealerInfo.PrincSal = " & Me.TxtPrincSal & ",
tblAlternateDealerInfo.PrincFirst = " & Me.TxtPrincFirst & ",
tblAlternateDealerInfo.PrincLast = " & Me.TxtPrincLast & ",
tblAlternateDealerInfo.PMsection = " & Me.TxtPM & ",
tblAlternateDealerInfo.PMname = " & Me.TxtPmname & ",
tblAlternateDealerInfo.PMnumber = " & Me.TxtPMnumber & ",
WHERE tblAlternateDealerInfo.PDN = " & Me.txtpdn.Value & ";
Else
qstr = "insert into [tblAlternateDealerInfo] (BC, PDN, WSN, Name,
Address, City, State, Zip, Phone, Fax, PrincSal, PrincFirst, PrincLast,
pmsection, pmname, PMnumber) values ( '" & Me.txtBC & "', '" &
Me.txtPDN & "', '" & Me.txtWSN & "', '" & Me.txtName & "', '" &
Me.txtAddress & "', '" & Me.txtCity & "', '" & Me.txtState & "', '" &
Me.txtZIP & "', '" & Me.txtPhone & "', '" & Me.txtFax & "', '" &
Me.TxtPrincSal & "', '" & Me.TxtPrincFirst & "', '" & Me.TxtPrincLast &
"', '" & Me.txtPM & "', '" & Me.txtPMName & "','" & Me.txtPMNumber &
"');"
DoCmd.RunSQL (qstr)
End If
Thanks
If PDN is in the table i would like to update that Record with some
txt boxes
If PDN is not in the table i want it to insert a New record
It sounds simple but i think i am doind something wrong
Here is the code... What is wrong with it?
Set rstedit = db.OpenRecordset("SELECT * FROM tblDocumentList WHERE
[num] = " & searchcrit)
If rstedit.RecordCount = 1 Then
QrySQL = "UPDATE [tblAlternateDealerInfo] "
Set tblAlternateDealerInfo.BC = " & Me.txtBC & ",
tblAlternateDealerInfo.PDN = " & Me.TxtPDN & ",
tblAlternateDealerInfo.WSN = " & Me.TxtWSN & ",
tblAlternateDealerInfo.Name = " & Me.TxtNAme & ",
tblAlternateDealerInfo.Address = " & Me.TxtAddress & ",
tblAlternateDealerInfo.City = " & Me.TxtCity & ",
tblAlternateDealerInfo.State = " & Me.TxtState & ",
tblAlternateDealerInfo.Zip = " & Me.TxtZip & ",
tblAlternateDealerInfo.Phone = " & Me.TxtPhone & ",
tblAlternateDealerInfo.Fax = " & Me.TxtFax & ",
tblAlternateDealerInfo.PrincSal = " & Me.TxtPrincSal & ",
tblAlternateDealerInfo.PrincFirst = " & Me.TxtPrincFirst & ",
tblAlternateDealerInfo.PrincLast = " & Me.TxtPrincLast & ",
tblAlternateDealerInfo.PMsection = " & Me.TxtPM & ",
tblAlternateDealerInfo.PMname = " & Me.TxtPmname & ",
tblAlternateDealerInfo.PMnumber = " & Me.TxtPMnumber & ",
WHERE tblAlternateDealerInfo.PDN = " & Me.txtpdn.Value & ";
Else
qstr = "insert into [tblAlternateDealerInfo] (BC, PDN, WSN, Name,
Address, City, State, Zip, Phone, Fax, PrincSal, PrincFirst, PrincLast,
pmsection, pmname, PMnumber) values ( '" & Me.txtBC & "', '" &
Me.txtPDN & "', '" & Me.txtWSN & "', '" & Me.txtName & "', '" &
Me.txtAddress & "', '" & Me.txtCity & "', '" & Me.txtState & "', '" &
Me.txtZIP & "', '" & Me.txtPhone & "', '" & Me.txtFax & "', '" &
Me.TxtPrincSal & "', '" & Me.TxtPrincFirst & "', '" & Me.TxtPrincLast &
"', '" & Me.txtPM & "', '" & Me.txtPMName & "','" & Me.txtPMNumber &
"');"
DoCmd.RunSQL (qstr)
End If
Thanks