Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Synchronizing Forms

Status
Not open for further replies.

pd2222

Programmer
Oct 15, 2001
14
0
0
GB
Hi,

I have written some code that inserts into the main table new data (Supplier's name) that is not in the combo box list (notinlist event). e.g:

Set dbsInvoice = CurrentDb()
Set rstTable = dbsInvoice.OpenRecordset("Supplier Table")

rstTable.AddNew
rstTable![SupplierName] = NewData
rstTable.Update
Response = acDataErrAdded

Following that I wish to open another form (Supplier's form) filtered on the NEW supplier's name.

I have tried the following code but it either opens on a blank record or if I do it twice it looks at the previous new data. Therefore I believe it has something to do with it not being saved even though it's been put into the Table.
NB: I cannot just add a save command as there are boxes
that would not have been completed at this point and
cannot contain a null value therefore creating an error
if saved!!

stDocName = "frm_Supplier Information"
stLinkCriteria = "[SupplierName]=" & "'" & Me!
[SupplierName] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria


I have tried all sorts of ways (including ones I got off of here yesterday in reply to jdwm2310)

Please can someone help its driving me mad!!

Keza
 
If it is a combo box, & bound to an ID field (as is normally the case), you need the linkcriteria to specify the underlying ID, not the SupplierName itself. If you run your form as normal, then open the immediate window, & enter ?[Forms]![FormName]![ComboBoxName] it should tell you what value this field contains. I would imagine this will be an integer value, & not a text one. Hence your LinkCriteria will need to be:
stLinkCriteria = "[SupplierID] = '" & Me![SupplierName] & "'"

perhaps this will solve your problem... James Goodman
j.goodman00@btinternet.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top