If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Add a new record is not immediately available on form
I believe you could use the combo box's Not In List event to open a small
data entry form for the purpose of adding the item. You could requery after closing the form. "LoriO" wrote: I have a Table: tblPlanType Query: qry_tblPlanType Form: frm_tblPlanType When I add a new record to the form, I have a FIELD (TDType) - (ComboBox) It's record source is a Query based off of the Table: tblPlanType ComboBox - Limit to List property is YES I want to add a response to the combo box and if it is not in the List I want to add it to the Table (tblPlanType) and be able to use it without having to start over on the record I was adding. The code below seems to partially work but I get an error: The text you entered isn't an item in the list How do I get the combo box to 'update immediately' after I have entered a new item in the Source Table? I have an Event Procedure on the "On Not in List" of the TdType Combo Box *********Code I am using*************** Private Sub TDType_NotInList(NewData As String, Response As Integer) Dim ctl As Control Dim rst As DAO.Recordset Dim db As DAO.Database Set ctl = Me!TDType If MsgBox("Value is not is list. Add it?", _ vbOKCancel) = vbOK Then Set db = CurrentDb() Set rst = db.OpenRecordset("qry_TblPlanType") With rst .AddNew .Fields("IssueType") = NewData .Update End With rst.Close Set rst = Nothing Set db = Nothing Repsonse = acDataErrAdded Else Response = acDataErrContinue ctl.Undo End If End Sub |
#2
|
|||
|
|||
I changed the code to Open a form if I choose vbOK,
I add the new record to the form, then Close it I have an 'on close' event to the form to requery the Original (frm_tblPlanType) form and I am still getting the error message: "The text you entered isn't an item in the list " I tried the requery on 'close' because when I tried it on the original code - I get an error that says I must save the record before I can requery. Do you have any examples of code that works with the 'requery' or can you tell me where to put the code - "BruceM" wrote: I believe you could use the combo box's Not In List event to open a small data entry form for the purpose of adding the item. You could requery after closing the form. "LoriO" wrote: I have a Table: tblPlanType Query: qry_tblPlanType Form: frm_tblPlanType When I add a new record to the form, I have a FIELD (TDType) - (ComboBox) It's record source is a Query based off of the Table: tblPlanType ComboBox - Limit to List property is YES I want to add a response to the combo box and if it is not in the List I want to add it to the Table (tblPlanType) and be able to use it without having to start over on the record I was adding. The code below seems to partially work but I get an error: The text you entered isn't an item in the list How do I get the combo box to 'update immediately' after I have entered a new item in the Source Table? I have an Event Procedure on the "On Not in List" of the TdType Combo Box *********Code I am using*************** Private Sub TDType_NotInList(NewData As String, Response As Integer) Dim ctl As Control Dim rst As DAO.Recordset Dim db As DAO.Database Set ctl = Me!TDType If MsgBox("Value is not is list. Add it?", _ vbOKCancel) = vbOK Then Set db = CurrentDb() Set rst = db.OpenRecordset("qry_TblPlanType") With rst .AddNew .Fields("IssueType") = NewData .Update End With rst.Close Set rst = Nothing Set db = Nothing Repsonse = acDataErrAdded Else Response = acDataErrContinue ctl.Undo End If End Sub |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
dealing with a subform record when it's "dirty" | Paul James | Using Forms | 8 | October 17th, 2004 08:45 AM |
Change and Save a Record | sara | Using Forms | 0 | July 17th, 2004 04:47 PM |
Copy an existing record into appropriate tables after modifying. | bdehning | General Discussion | 8 | July 7th, 2004 08:44 AM |
How to get Current Record from the subform with the datasheet | Tom | Using Forms | 1 | June 18th, 2004 12:35 PM |
Form Doesn't Go To New Record | Steve | New Users | 15 | May 16th, 2004 04:33 PM |