New Record in Combo-->2 records on save!

A

ABL

Hello,
I have a combo box that will add a new record in a bound form if not in
list. My problem is:
1) when I add my first item into the combo box, edit the data and then
save, I wind up with two records: the first with the (autonum)
vendor_id, (client modifiable)vnum and vendorname, and the second with
everything else (plus the vendornum, in its newly modified state).

I am using A2k. The relevant code is:
from vendnamelist__NotInList:
Dim vendnum As Integer
If MsgBox("Are you sure you want to add a vendor named, """ _
& NewData & """?", vbQuestion + vbYesNo, "Add New Vendor") = vbNo Then
Me!vendnamelist = Null
Exit Sub
End If
vendnum = 0
Do
vendnum = vendnum + 1
Loop Until DCount("*", "vendor", "[vnum] = " & vendnum) = 0
response = acbAddNewVendRecord(NewData, vendnum)
Me!vendnamelist = newvend_id
Me![vendnamelist].Requery
Me!vendor_num = vendnum
Me!vendor_num.SetFocus
Me!origin_num = Null
Me!address = Null
Me!city_name = Null
Me!state_name = Null
Me!zip_code = Null
Me!notes_box = Null

from acbAddNewVendRecord:
Dim rst As Object

Set rst = DBEngine.Workspaces(0).Databases(0).OpenRecordset("vendor")
rst.AddNew
rst!vendorname = strNewData
rst!vnum = ID_num
newvend_id = rst!vendor_id
rst.Update
rst.Close
Set rst = Nothing

acbAddNewVendRecord = acDataErrAdded

and from Save_Vendor_Click:
Dim response As Integer
On Error GoTo Err_Save_Vendor_Click

Me![vnum] = Me!vendor_num
Me![origincode] = Me!origin_num
Me![address1] = Me!address
Me![city] = Me!city_name
Me![state] = Me!state_name
Me![zip] = Me!zip_code
Me![notes] = Me!notes_box
Me![status] = True

'DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Me.Dirty = False

Clearly, I am doing something wrong. Any advice?

Thanks,
Alden

PLEASE do not reply to this address. I do not check it and I use it to
catch unsolicited email. Thanks.
 

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