A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Add a new record is not immediately available on form



 
 
Thread Tools Display Modes
  #1  
Old May 31st, 2005, 11:53 PM
BruceM
external usenet poster
 
Posts: n/a
Default 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  
Old June 1st, 2005, 12:08 AM
LoriO
external usenet poster
 
Posts: n/a
Default

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 04:05 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.