B
Bill
Hi all,
i have a mainform (Enquiry) with a subform on it listing products ordered
(subEnquiryDetails)..
I have an airconditioner calculator form that basically accepts some
variables (house/premise attributes, size of room etc), and outputs suitable
airconditioner products. Depending on the airconditioner the user selects,
i wish for the program to automatically insert the selected product into the
subOrder form on the main Orders form. I have managed to do this, but only
when a particular circumstance occurs:
I must select (not insert any data) the first textbox in my datasheet. Once
this occurs, the INSERT INTO statement ran from the other form works fine.
This is really weird. I have tried using the setfocus method from code to
'simulate' this, but to no avail. I am really stuck between a rock and a
hard place.
my code is as follows:
Forms!Enquiry!subEnquiryDetails.Form.cboProductID.SetFocus
Forms!Enquiry!subEnquiryDetails.Form.cboProductID.Requery
Forms!Enquiry!subEnquiryDetails.Form.Requery
Forms!Enquiry!subEnquiryDetails.Form.Refresh
s = "INSERT INTO EnquiryDetails (EnquiryID, ProductID, Price,
Qty,
Discount,Description,FreightCost,TravelCost,ExtrasDesc,ExtrasValue) " & _
"VALUES ('" & Forms!Enquiry!ReferenceNo & "', '" &
Val(AirconID) & "', '" & Val(AirconPrice) & "', " & _
"1,0,'',0,0,'',0)"
db.Execute s, dbFailOnError
When i try and run the code, i get the following error message:
"You cannot add or change a record because a related record is required in
table 'ProductEnquiry' "
If i run the code, and set the focus WITH MY MOUSE on the subform, it works
fine.
can anybody help me please??????????????????????????
Regards,
Bill
i have a mainform (Enquiry) with a subform on it listing products ordered
(subEnquiryDetails)..
I have an airconditioner calculator form that basically accepts some
variables (house/premise attributes, size of room etc), and outputs suitable
airconditioner products. Depending on the airconditioner the user selects,
i wish for the program to automatically insert the selected product into the
subOrder form on the main Orders form. I have managed to do this, but only
when a particular circumstance occurs:
I must select (not insert any data) the first textbox in my datasheet. Once
this occurs, the INSERT INTO statement ran from the other form works fine.
This is really weird. I have tried using the setfocus method from code to
'simulate' this, but to no avail. I am really stuck between a rock and a
hard place.
my code is as follows:
Forms!Enquiry!subEnquiryDetails.Form.cboProductID.SetFocus
Forms!Enquiry!subEnquiryDetails.Form.cboProductID.Requery
Forms!Enquiry!subEnquiryDetails.Form.Requery
Forms!Enquiry!subEnquiryDetails.Form.Refresh
s = "INSERT INTO EnquiryDetails (EnquiryID, ProductID, Price,
Qty,
Discount,Description,FreightCost,TravelCost,ExtrasDesc,ExtrasValue) " & _
"VALUES ('" & Forms!Enquiry!ReferenceNo & "', '" &
Val(AirconID) & "', '" & Val(AirconPrice) & "', " & _
"1,0,'',0,0,'',0)"
db.Execute s, dbFailOnError
When i try and run the code, i get the following error message:
"You cannot add or change a record because a related record is required in
table 'ProductEnquiry' "
If i run the code, and set the focus WITH MY MOUSE on the subform, it works
fine.
can anybody help me please??????????????????????????
Regards,
Bill