Combo Box "not in list" handling

  • Thread starter Thread starter NES
  • Start date Start date
N

NES

When filling out a form that has combo boxes, very often I find data is not
yet in the dropdown list. (Data appearing in the list is entered through
another form.)

I've seen that option in the properties list, and I see that it requires the
bound column to show. But then what? I still can't enter data into the "other
form" in order to complete the form I'm working in. I can trigger a jump out
of the current form and display the required input form, but besides not
being very elligant, it wastes an auto-number record number in the original
form. The problem is worse if more than one combo box is involved on the
form.

Any help would be appreciated. Thanks in advance.
 
Hi Norm,
To add a non existing value to the combo add this code to the on not in list
event of your combo:

Dim recdata As Recordset

If Not IsNull(NewData) And NewData <> "" Then
Set recdata =
currentdb.OpenRecordset("NAMEOFTHETABLESOURCEFORTHECOMBO", dbOpenDynaset)
recdata.AddNew
recdata![NAMEOFTHEFIELDINTHETABLESOURCE] = NewData
recdata.Update
recdata.Move 0, recdata.LastModified
Me![NAMEOFTHECOMBO] =
recdata![NAMEOFTHEAUTONUMBEFIELDINTHETABLESOURCE]
recdata.Close
Me![NAMEOFTHECOMBO].Requery
Response = DATA_ERRCONTINUE
Else
Me![NAMEOFTHECOMBO] = Null
Response = DATA_ERRADDED
End If

Subsitute the capitalised name (that describes briefly what is attended
there) with your names and it should work.

HTH Paolo
 
Paolo, thank you very much for the help. It looks complicated to someone not
that familiar with VBA. I'll see what I can do with it. <S> Thanks again.
--
Norm Shimmel
Butler, PA


Paolo said:
Hi Norm,
To add a non existing value to the combo add this code to the on not in list
event of your combo:

Dim recdata As Recordset

If Not IsNull(NewData) And NewData <> "" Then
Set recdata =
currentdb.OpenRecordset("NAMEOFTHETABLESOURCEFORTHECOMBO", dbOpenDynaset)
recdata.AddNew
recdata![NAMEOFTHEFIELDINTHETABLESOURCE] = NewData
recdata.Update
recdata.Move 0, recdata.LastModified
Me![NAMEOFTHECOMBO] =
recdata![NAMEOFTHEAUTONUMBEFIELDINTHETABLESOURCE]
recdata.Close
Me![NAMEOFTHECOMBO].Requery
Response = DATA_ERRCONTINUE
Else
Me![NAMEOFTHECOMBO] = Null
Response = DATA_ERRADDED
End If

Subsitute the capitalised name (that describes briefly what is attended
there) with your names and it should work.

HTH Paolo


NES said:
When filling out a form that has combo boxes, very often I find data is not
yet in the dropdown list. (Data appearing in the list is entered through
another form.)

I've seen that option in the properties list, and I see that it requires the
bound column to show. But then what? I still can't enter data into the "other
form" in order to complete the form I'm working in. I can trigger a jump out
of the current form and display the required input form, but besides not
being very elligant, it wastes an auto-number record number in the original
form. The problem is worse if more than one combo box is involved on the
form.

Any help would be appreciated. Thanks in advance.
 
It is faster and less code to use an SQL Insert in this case:

Dim strSQL As String

If Nz(NewData,vbNullString) = vbNullString Then
If MsgBox(NewData & " Not Found - Add To List", vbQuestion +
vbYesNo) & _
= vbNo Then
Me.MyCombo.Undo
Response = acDataErrContinue
Else
strSQL = "INSERT INTO SomeTable ( SomeField ) SELECT " & _
NewData & " AS NewVal;"
Currentdb.Execute strSQL, dbFailOnError
Me.MyComb.Requery
Me.MyCombo = NewData
Response = acDataErrAdded
End If

--
Dave Hargis, Microsoft Access MVP


Paolo said:
Hi Norm,
To add a non existing value to the combo add this code to the on not in list
event of your combo:

Dim recdata As Recordset

If Not IsNull(NewData) And NewData <> "" Then
Set recdata =
currentdb.OpenRecordset("NAMEOFTHETABLESOURCEFORTHECOMBO", dbOpenDynaset)
recdata.AddNew
recdata![NAMEOFTHEFIELDINTHETABLESOURCE] = NewData
recdata.Update
recdata.Move 0, recdata.LastModified
Me![NAMEOFTHECOMBO] =
recdata![NAMEOFTHEAUTONUMBEFIELDINTHETABLESOURCE]
recdata.Close
Me![NAMEOFTHECOMBO].Requery
Response = DATA_ERRCONTINUE
Else
Me![NAMEOFTHECOMBO] = Null
Response = DATA_ERRADDED
End If

Subsitute the capitalised name (that describes briefly what is attended
there) with your names and it should work.

HTH Paolo


NES said:
When filling out a form that has combo boxes, very often I find data is not
yet in the dropdown list. (Data appearing in the list is entered through
another form.)

I've seen that option in the properties list, and I see that it requires the
bound column to show. But then what? I still can't enter data into the "other
form" in order to complete the form I'm working in. I can trigger a jump out
of the current form and display the required input form, but besides not
being very elligant, it wastes an auto-number record number in the original
form. The problem is worse if more than one combo box is involved on the
form.

Any help would be appreciated. Thanks in advance.
 
When filling out a form that has combo boxes, very often I find data is not
yet in the dropdown list. (Data appearing in the list is entered through
another form.)

I've seen that option in the properties list, and I see that it requires the
bound column to show. But then what? I still can't enter data into the "other
form" in order to complete the form I'm working in. I can trigger a jump out
of the current form and display the required input form, but besides not
being very elligant, it wastes an auto-number record number in the original
form. The problem is worse if more than one combo box is involved on the
form.

Any help would be appreciated. Thanks in advance.

If you must open a form to add the new data (it isn't necessary in
most instances), you can code the Combo Box's NotInList event:

If MsgBox("The Agency Entered is not in database, would you like to
add it?", vbYesNo) = vbYes Then
DoCmd.OpenForm "FormName", , , , acFormAdd, acDialog, NewData
Response = acDataErrAdded
End If

Code the "FormName" Load event:
If Not IsNull(Me.OpenArgs) Then
Me.[ControlName] = Me.OpenArgs
End If

The form will open with the newly added data in the field.
You can then continue filling in additional information on this form,
such as Agency address, Phone, Contact name, etc.
When you close this form, you will be back in the original form and
the entry will be in the combo box list.

If you do not really need to open a form to enter the new data into
(because other than the one Item, there is no additional associated
data to fill in) you can use a simple Append query code to add the new
data.

If MsgBox("The Item Entered is not in database, would you like to add
it?", vbYesNo) = vbYes Then
CurrentDb.Execute " INSERT INTO TableName(FieldName) Select " &
Chr(34) & NewData & Chr(34) & ";", dbFailOnError
Response = acDataErrAdded
End If
 
Thank you very much for your assistance. I'll have to study this for awhile
as I have the other in order to see what is happening. Though I have years of
experience in programming, I'm a rank beginner in VBA or for that matter VB.
Thanks again.

What I've been doing is a call to a macro to do several {escape}s then a
call to open the correct form for input. But it bounces me out of the form
I'm in. If I don't issue the escapes, I can still call the input form, but
when done, I don't seem to be able to refresh the tables properly. Even a
button on the form seems to be ignored, and I'm still in an error condition
apparently.

Thanks again.
--
Norm Shimmel
Butler, PA


Klatuu said:
It is faster and less code to use an SQL Insert in this case:

Dim strSQL As String

If Nz(NewData,vbNullString) = vbNullString Then
If MsgBox(NewData & " Not Found - Add To List", vbQuestion +
vbYesNo) & _
= vbNo Then
Me.MyCombo.Undo
Response = acDataErrContinue
Else
strSQL = "INSERT INTO SomeTable ( SomeField ) SELECT " & _
NewData & " AS NewVal;"
Currentdb.Execute strSQL, dbFailOnError
Me.MyComb.Requery
Me.MyCombo = NewData
Response = acDataErrAdded
End If

--
Dave Hargis, Microsoft Access MVP


Paolo said:
Hi Norm,
To add a non existing value to the combo add this code to the on not in list
event of your combo:

Dim recdata As Recordset

If Not IsNull(NewData) And NewData <> "" Then
Set recdata =
currentdb.OpenRecordset("NAMEOFTHETABLESOURCEFORTHECOMBO", dbOpenDynaset)
recdata.AddNew
recdata![NAMEOFTHEFIELDINTHETABLESOURCE] = NewData
recdata.Update
recdata.Move 0, recdata.LastModified
Me![NAMEOFTHECOMBO] =
recdata![NAMEOFTHEAUTONUMBEFIELDINTHETABLESOURCE]
recdata.Close
Me![NAMEOFTHECOMBO].Requery
Response = DATA_ERRCONTINUE
Else
Me![NAMEOFTHECOMBO] = Null
Response = DATA_ERRADDED
End If

Subsitute the capitalised name (that describes briefly what is attended
there) with your names and it should work.

HTH Paolo


NES said:
When filling out a form that has combo boxes, very often I find data is not
yet in the dropdown list. (Data appearing in the list is entered through
another form.)

I've seen that option in the properties list, and I see that it requires the
bound column to show. But then what? I still can't enter data into the "other
form" in order to complete the form I'm working in. I can trigger a jump out
of the current form and display the required input form, but besides not
being very elligant, it wastes an auto-number record number in the original
form. The problem is worse if more than one combo box is involved on the
form.

Any help would be appreciated. Thanks in advance.
 
Yet another possible solution. Thank you very very much. I'm saving all of
these by the way. I'll check this out too.
--
Norm Shimmel
Butler, PA


fredg said:
When filling out a form that has combo boxes, very often I find data is not
yet in the dropdown list. (Data appearing in the list is entered through
another form.)

I've seen that option in the properties list, and I see that it requires the
bound column to show. But then what? I still can't enter data into the "other
form" in order to complete the form I'm working in. I can trigger a jump out
of the current form and display the required input form, but besides not
being very elligant, it wastes an auto-number record number in the original
form. The problem is worse if more than one combo box is involved on the
form.

Any help would be appreciated. Thanks in advance.

If you must open a form to add the new data (it isn't necessary in
most instances), you can code the Combo Box's NotInList event:

If MsgBox("The Agency Entered is not in database, would you like to
add it?", vbYesNo) = vbYes Then
DoCmd.OpenForm "FormName", , , , acFormAdd, acDialog, NewData
Response = acDataErrAdded
End If

Code the "FormName" Load event:
If Not IsNull(Me.OpenArgs) Then
Me.[ControlName] = Me.OpenArgs
End If

The form will open with the newly added data in the field.
You can then continue filling in additional information on this form,
such as Agency address, Phone, Contact name, etc.
When you close this form, you will be back in the original form and
the entry will be in the combo box list.

If you do not really need to open a form to enter the new data into
(because other than the one Item, there is no additional associated
data to fill in) you can use a simple Append query code to add the new
data.

If MsgBox("The Item Entered is not in database, would you like to add
it?", vbYesNo) = vbYes Then
CurrentDb.Execute " INSERT INTO TableName(FieldName) Select " &
Chr(34) & NewData & Chr(34) & ";", dbFailOnError
Response = acDataErrAdded
End If
 
Could you describe exactly what you are wanting to happen and what is
actually happening, and of course, what you are doing to try to make it
happen.
--
Dave Hargis, Microsoft Access MVP


NES said:
Thank you very much for your assistance. I'll have to study this for awhile
as I have the other in order to see what is happening. Though I have years of
experience in programming, I'm a rank beginner in VBA or for that matter VB.
Thanks again.

What I've been doing is a call to a macro to do several {escape}s then a
call to open the correct form for input. But it bounces me out of the form
I'm in. If I don't issue the escapes, I can still call the input form, but
when done, I don't seem to be able to refresh the tables properly. Even a
button on the form seems to be ignored, and I'm still in an error condition
apparently.

Thanks again.
--
Norm Shimmel
Butler, PA


Klatuu said:
It is faster and less code to use an SQL Insert in this case:

Dim strSQL As String

If Nz(NewData,vbNullString) = vbNullString Then
If MsgBox(NewData & " Not Found - Add To List", vbQuestion +
vbYesNo) & _
= vbNo Then
Me.MyCombo.Undo
Response = acDataErrContinue
Else
strSQL = "INSERT INTO SomeTable ( SomeField ) SELECT " & _
NewData & " AS NewVal;"
Currentdb.Execute strSQL, dbFailOnError
Me.MyComb.Requery
Me.MyCombo = NewData
Response = acDataErrAdded
End If

--
Dave Hargis, Microsoft Access MVP


Paolo said:
Hi Norm,
To add a non existing value to the combo add this code to the on not in list
event of your combo:

Dim recdata As Recordset

If Not IsNull(NewData) And NewData <> "" Then
Set recdata =
currentdb.OpenRecordset("NAMEOFTHETABLESOURCEFORTHECOMBO", dbOpenDynaset)
recdata.AddNew
recdata![NAMEOFTHEFIELDINTHETABLESOURCE] = NewData
recdata.Update
recdata.Move 0, recdata.LastModified
Me![NAMEOFTHECOMBO] =
recdata![NAMEOFTHEAUTONUMBEFIELDINTHETABLESOURCE]
recdata.Close
Me![NAMEOFTHECOMBO].Requery
Response = DATA_ERRCONTINUE
Else
Me![NAMEOFTHECOMBO] = Null
Response = DATA_ERRADDED
End If

Subsitute the capitalised name (that describes briefly what is attended
there) with your names and it should work.

HTH Paolo


:

When filling out a form that has combo boxes, very often I find data is not
yet in the dropdown list. (Data appearing in the list is entered through
another form.)

I've seen that option in the properties list, and I see that it requires the
bound column to show. But then what? I still can't enter data into the "other
form" in order to complete the form I'm working in. I can trigger a jump out
of the current form and display the required input form, but besides not
being very elligant, it wastes an auto-number record number in the original
form. The problem is worse if more than one combo box is involved on the
form.

Any help would be appreciated. Thanks in advance.
 
Based on your earlier description of the problem, fredg's code for opening a
data entry form to add the record may be the easiest way to do this. But, If
the form you need to enter the new record in is the form you currently have
open, you would do it a little differently. You would just go to a new
record and populate the appropriate field with the NewData value.
--
Dave Hargis, Microsoft Access MVP


NES said:
Yet another possible solution. Thank you very very much. I'm saving all of
these by the way. I'll check this out too.
--
Norm Shimmel
Butler, PA


fredg said:
When filling out a form that has combo boxes, very often I find data is not
yet in the dropdown list. (Data appearing in the list is entered through
another form.)

I've seen that option in the properties list, and I see that it requires the
bound column to show. But then what? I still can't enter data into the "other
form" in order to complete the form I'm working in. I can trigger a jump out
of the current form and display the required input form, but besides not
being very elligant, it wastes an auto-number record number in the original
form. The problem is worse if more than one combo box is involved on the
form.

Any help would be appreciated. Thanks in advance.

If you must open a form to add the new data (it isn't necessary in
most instances), you can code the Combo Box's NotInList event:

If MsgBox("The Agency Entered is not in database, would you like to
add it?", vbYesNo) = vbYes Then
DoCmd.OpenForm "FormName", , , , acFormAdd, acDialog, NewData
Response = acDataErrAdded
End If

Code the "FormName" Load event:
If Not IsNull(Me.OpenArgs) Then
Me.[ControlName] = Me.OpenArgs
End If

The form will open with the newly added data in the field.
You can then continue filling in additional information on this form,
such as Agency address, Phone, Contact name, etc.
When you close this form, you will be back in the original form and
the entry will be in the combo box list.

If you do not really need to open a form to enter the new data into
(because other than the one Item, there is no additional associated
data to fill in) you can use a simple Append query code to add the new
data.

If MsgBox("The Item Entered is not in database, would you like to add
it?", vbYesNo) = vbYes Then
CurrentDb.Execute " INSERT INTO TableName(FieldName) Select " &
Chr(34) & NewData & Chr(34) & ";", dbFailOnError
Response = acDataErrAdded
End If
 
Thank you so much. I am refining a working application dealing with health
clinic prescription medication distribution. The ideal is that the patient's
data is already in the table and can be selected from a combo box by means of
the last 4 SS digits (with confirmation of name) or by typing the name in a
different combo box.

The selection holds true for the prescribing physician (by name only) who
ordinarily is already employed in the clinic. However, we fill prescriptions
from "outside" physicians as well, and they may or may not be in the
Physicians table.

So unless we check the two tables before begining the prescription entry,
that entry can be a crap shoot. The physician's data is just a name, but the
patient's info includes name, address, phone, etc.

Thanks again.

--
Norm Shimmel
Butler, PA


Klatuu said:
Based on your earlier description of the problem, fredg's code for opening a
data entry form to add the record may be the easiest way to do this. But, If
the form you need to enter the new record in is the form you currently have
open, you would do it a little differently. You would just go to a new
record and populate the appropriate field with the NewData value.
--
Dave Hargis, Microsoft Access MVP


NES said:
Yet another possible solution. Thank you very very much. I'm saving all of
these by the way. I'll check this out too.
--
Norm Shimmel
Butler, PA


fredg said:
On Thu, 8 May 2008 06:31:01 -0700, NES wrote:

When filling out a form that has combo boxes, very often I find data is not
yet in the dropdown list. (Data appearing in the list is entered through
another form.)

I've seen that option in the properties list, and I see that it requires the
bound column to show. But then what? I still can't enter data into the "other
form" in order to complete the form I'm working in. I can trigger a jump out
of the current form and display the required input form, but besides not
being very elligant, it wastes an auto-number record number in the original
form. The problem is worse if more than one combo box is involved on the
form.

Any help would be appreciated. Thanks in advance.

If you must open a form to add the new data (it isn't necessary in
most instances), you can code the Combo Box's NotInList event:

If MsgBox("The Agency Entered is not in database, would you like to
add it?", vbYesNo) = vbYes Then
DoCmd.OpenForm "FormName", , , , acFormAdd, acDialog, NewData
Response = acDataErrAdded
End If

Code the "FormName" Load event:
If Not IsNull(Me.OpenArgs) Then
Me.[ControlName] = Me.OpenArgs
End If

The form will open with the newly added data in the field.
You can then continue filling in additional information on this form,
such as Agency address, Phone, Contact name, etc.
When you close this form, you will be back in the original form and
the entry will be in the combo box list.

If you do not really need to open a form to enter the new data into
(because other than the one Item, there is no additional associated
data to fill in) you can use a simple Append query code to add the new
data.

If MsgBox("The Item Entered is not in database, would you like to add
it?", vbYesNo) = vbYes Then
CurrentDb.Execute " INSERT INTO TableName(FieldName) Select " &
Chr(34) & NewData & Chr(34) & ";", dbFailOnError
Response = acDataErrAdded
End If
 
So you are saying there is a table for physicians and a table for patients
and there are forms for entering data for each of these. Or in the case of
physician, it is only a name? And that the form you are entering data in is
not the form you would be entering patient information in? And, the form you
are working from is a different form where you enter prescription information
for the patient?

--
Dave Hargis, Microsoft Access MVP


NES said:
Thank you so much. I am refining a working application dealing with health
clinic prescription medication distribution. The ideal is that the patient's
data is already in the table and can be selected from a combo box by means of
the last 4 SS digits (with confirmation of name) or by typing the name in a
different combo box.

The selection holds true for the prescribing physician (by name only) who
ordinarily is already employed in the clinic. However, we fill prescriptions
from "outside" physicians as well, and they may or may not be in the
Physicians table.

So unless we check the two tables before begining the prescription entry,
that entry can be a crap shoot. The physician's data is just a name, but the
patient's info includes name, address, phone, etc.

Thanks again.

--
Norm Shimmel
Butler, PA


Klatuu said:
Based on your earlier description of the problem, fredg's code for opening a
data entry form to add the record may be the easiest way to do this. But, If
the form you need to enter the new record in is the form you currently have
open, you would do it a little differently. You would just go to a new
record and populate the appropriate field with the NewData value.
--
Dave Hargis, Microsoft Access MVP


NES said:
Yet another possible solution. Thank you very very much. I'm saving all of
these by the way. I'll check this out too.
--
Norm Shimmel
Butler, PA


:

On Thu, 8 May 2008 06:31:01 -0700, NES wrote:

When filling out a form that has combo boxes, very often I find data is not
yet in the dropdown list. (Data appearing in the list is entered through
another form.)

I've seen that option in the properties list, and I see that it requires the
bound column to show. But then what? I still can't enter data into the "other
form" in order to complete the form I'm working in. I can trigger a jump out
of the current form and display the required input form, but besides not
being very elligant, it wastes an auto-number record number in the original
form. The problem is worse if more than one combo box is involved on the
form.

Any help would be appreciated. Thanks in advance.

If you must open a form to add the new data (it isn't necessary in
most instances), you can code the Combo Box's NotInList event:

If MsgBox("The Agency Entered is not in database, would you like to
add it?", vbYesNo) = vbYes Then
DoCmd.OpenForm "FormName", , , , acFormAdd, acDialog, NewData
Response = acDataErrAdded
End If

Code the "FormName" Load event:
If Not IsNull(Me.OpenArgs) Then
Me.[ControlName] = Me.OpenArgs
End If

The form will open with the newly added data in the field.
You can then continue filling in additional information on this form,
such as Agency address, Phone, Contact name, etc.
When you close this form, you will be back in the original form and
the entry will be in the combo box list.

If you do not really need to open a form to enter the new data into
(because other than the one Item, there is no additional associated
data to fill in) you can use a simple Append query code to add the new
data.

If MsgBox("The Item Entered is not in database, would you like to add
it?", vbYesNo) = vbYes Then
CurrentDb.Execute " INSERT INTO TableName(FieldName) Select " &
Chr(34) & NewData & Chr(34) & ";", dbFailOnError
Response = acDataErrAdded
End If
 
Yes, that's correct. The so-called physicians table in fact includes Nurse
Practitioners, and is called the "Professionals table". It contains three
fields: name, specialty (Physician, NP, Dentist, Etc.) and the federal DEA
number. This data is used as historical data and label printing of course. I
just learned that we are NOT filling prescriptions written by outside
physicians, so this aspect is not a problem. But the problem remains for
patients who may not appear in the combo box. That should NOT occur, because
they should be asked if they've received prescriptions before. But you know
how that goes...!

The form for preparing prescriptions is rather more complicated, and in fact
contains 3 sub forms for various reasons. It is not only the primary
prescription form for the table of the same name, but one subform in it takes
care of the details of the original filling and all refills filed in the
Prescription Details table. This table is displayed in a continuous form
within the primary form, and is used to track medications as well as costs
for various reports.

Of course, since this is a relational DB, only the record number for the
patient, physician, and medication, is retained in the primary prescription
table along with instructions, quanty, number of refills allowed, date, etc.

Combo boxes are used to select patient by the last 4 of the social security
number (with confirmation of name) OR by typing in the LAST NAME, FIRST NAME.

Physician is selected by name from a combo box, as is the medication. When
all of this info has been entered into the primary form, entry flow moves to
the details sub form to allow input of what filling or refill it is, the
number actually dispensed (which can differ depending of availability),
auto-date, and then preview and printing of the label.

Refills are a breeze. Enter the prescription number at the top of the form,
and move to the details sub form for one entry (refill #) and accepting the
default number dispensed. Couple of clicks and you have the label and the
record is saved.

Each time that prescription is viewed, you see the entire history of
fillings, running total of fillings, running total of units (tabs, pills,
etc.) dispensed, as well as all the primary info.
--
Norm Shimmel
Butler, PA


Klatuu said:
So you are saying there is a table for physicians and a table for patients
and there are forms for entering data for each of these. Or in the case of
physician, it is only a name? And that the form you are entering data in is
not the form you would be entering patient information in? And, the form you
are working from is a different form where you enter prescription information
for the patient?

--
Dave Hargis, Microsoft Access MVP


NES said:
Thank you so much. I am refining a working application dealing with health
clinic prescription medication distribution. The ideal is that the patient's
data is already in the table and can be selected from a combo box by means of
the last 4 SS digits (with confirmation of name) or by typing the name in a
different combo box.

The selection holds true for the prescribing physician (by name only) who
ordinarily is already employed in the clinic. However, we fill prescriptions
from "outside" physicians as well, and they may or may not be in the
Physicians table.

So unless we check the two tables before begining the prescription entry,
that entry can be a crap shoot. The physician's data is just a name, but the
patient's info includes name, address, phone, etc.

Thanks again.

--
Norm Shimmel
Butler, PA


Klatuu said:
Based on your earlier description of the problem, fredg's code for opening a
data entry form to add the record may be the easiest way to do this. But, If
the form you need to enter the new record in is the form you currently have
open, you would do it a little differently. You would just go to a new
record and populate the appropriate field with the NewData value.
--
Dave Hargis, Microsoft Access MVP


:

Yet another possible solution. Thank you very very much. I'm saving all of
these by the way. I'll check this out too.
--
Norm Shimmel
Butler, PA


:

On Thu, 8 May 2008 06:31:01 -0700, NES wrote:

When filling out a form that has combo boxes, very often I find data is not
yet in the dropdown list. (Data appearing in the list is entered through
another form.)

I've seen that option in the properties list, and I see that it requires the
bound column to show. But then what? I still can't enter data into the "other
form" in order to complete the form I'm working in. I can trigger a jump out
of the current form and display the required input form, but besides not
being very elligant, it wastes an auto-number record number in the original
form. The problem is worse if more than one combo box is involved on the
form.

Any help would be appreciated. Thanks in advance.

If you must open a form to add the new data (it isn't necessary in
most instances), you can code the Combo Box's NotInList event:

If MsgBox("The Agency Entered is not in database, would you like to
add it?", vbYesNo) = vbYes Then
DoCmd.OpenForm "FormName", , , , acFormAdd, acDialog, NewData
Response = acDataErrAdded
End If

Code the "FormName" Load event:
If Not IsNull(Me.OpenArgs) Then
Me.[ControlName] = Me.OpenArgs
End If

The form will open with the newly added data in the field.
You can then continue filling in additional information on this form,
such as Agency address, Phone, Contact name, etc.
When you close this form, you will be back in the original form and
the entry will be in the combo box list.

If you do not really need to open a form to enter the new data into
(because other than the one Item, there is no additional associated
data to fill in) you can use a simple Append query code to add the new
data.

If MsgBox("The Item Entered is not in database, would you like to add
it?", vbYesNo) = vbYes Then
CurrentDb.Execute " INSERT INTO TableName(FieldName) Select " &
Chr(34) & NewData & Chr(34) & ";", dbFailOnError
Response = acDataErrAdded
End If
 
Okay, thanks
I would then recommend the method that fredg proposed. That is opening form
in data entry mode and passing the value of the NewData variable to the form
in the OpenArgs argument.

There is one other issue to deal with. That is that the new patient will
not yet be in your prescription form's recordset, so you will have to requery
the form after you have added the new patient. I would suggest you open the
form using acDialog. That will cause the code in the prescription form to
suspend until the patient form is closed. Then, requery the prescription
form. Now, that brings up another issue. When you requery a form, to goes
to the first record in the form' recordset, so you have to save the value of
the primary key of the current record so you can move back to it after the
requery. So it would go something like:

Dim lngPrimeKey As Long

DoCmd.OpenForm "FormName", , , , acFormAdd, acDialog, NewData

lngPrimeKey = Me.txtPrimeKeyControl
Me.Requery
With Me.RecordsetClone
.FindFirst "[PrimeKeyField] = " & lngPrimeKey
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With

Me.TxtSomeControl = NewData
--
Dave Hargis, Microsoft Access MVP


NES said:
Yes, that's correct. The so-called physicians table in fact includes Nurse
Practitioners, and is called the "Professionals table". It contains three
fields: name, specialty (Physician, NP, Dentist, Etc.) and the federal DEA
number. This data is used as historical data and label printing of course. I
just learned that we are NOT filling prescriptions written by outside
physicians, so this aspect is not a problem. But the problem remains for
patients who may not appear in the combo box. That should NOT occur, because
they should be asked if they've received prescriptions before. But you know
how that goes...!

The form for preparing prescriptions is rather more complicated, and in fact
contains 3 sub forms for various reasons. It is not only the primary
prescription form for the table of the same name, but one subform in it takes
care of the details of the original filling and all refills filed in the
Prescription Details table. This table is displayed in a continuous form
within the primary form, and is used to track medications as well as costs
for various reports.

Of course, since this is a relational DB, only the record number for the
patient, physician, and medication, is retained in the primary prescription
table along with instructions, quanty, number of refills allowed, date, etc.

Combo boxes are used to select patient by the last 4 of the social security
number (with confirmation of name) OR by typing in the LAST NAME, FIRST NAME.

Physician is selected by name from a combo box, as is the medication. When
all of this info has been entered into the primary form, entry flow moves to
the details sub form to allow input of what filling or refill it is, the
number actually dispensed (which can differ depending of availability),
auto-date, and then preview and printing of the label.

Refills are a breeze. Enter the prescription number at the top of the form,
and move to the details sub form for one entry (refill #) and accepting the
default number dispensed. Couple of clicks and you have the label and the
record is saved.

Each time that prescription is viewed, you see the entire history of
fillings, running total of fillings, running total of units (tabs, pills,
etc.) dispensed, as well as all the primary info.
--
Norm Shimmel
Butler, PA


Klatuu said:
So you are saying there is a table for physicians and a table for patients
and there are forms for entering data for each of these. Or in the case of
physician, it is only a name? And that the form you are entering data in is
not the form you would be entering patient information in? And, the form you
are working from is a different form where you enter prescription information
for the patient?

--
Dave Hargis, Microsoft Access MVP


NES said:
Thank you so much. I am refining a working application dealing with health
clinic prescription medication distribution. The ideal is that the patient's
data is already in the table and can be selected from a combo box by means of
the last 4 SS digits (with confirmation of name) or by typing the name in a
different combo box.

The selection holds true for the prescribing physician (by name only) who
ordinarily is already employed in the clinic. However, we fill prescriptions
from "outside" physicians as well, and they may or may not be in the
Physicians table.

So unless we check the two tables before begining the prescription entry,
that entry can be a crap shoot. The physician's data is just a name, but the
patient's info includes name, address, phone, etc.

Thanks again.

--
Norm Shimmel
Butler, PA


:

Based on your earlier description of the problem, fredg's code for opening a
data entry form to add the record may be the easiest way to do this. But, If
the form you need to enter the new record in is the form you currently have
open, you would do it a little differently. You would just go to a new
record and populate the appropriate field with the NewData value.
--
Dave Hargis, Microsoft Access MVP


:

Yet another possible solution. Thank you very very much. I'm saving all of
these by the way. I'll check this out too.
--
Norm Shimmel
Butler, PA


:

On Thu, 8 May 2008 06:31:01 -0700, NES wrote:

When filling out a form that has combo boxes, very often I find data is not
yet in the dropdown list. (Data appearing in the list is entered through
another form.)

I've seen that option in the properties list, and I see that it requires the
bound column to show. But then what? I still can't enter data into the "other
form" in order to complete the form I'm working in. I can trigger a jump out
of the current form and display the required input form, but besides not
being very elligant, it wastes an auto-number record number in the original
form. The problem is worse if more than one combo box is involved on the
form.

Any help would be appreciated. Thanks in advance.

If you must open a form to add the new data (it isn't necessary in
most instances), you can code the Combo Box's NotInList event:

If MsgBox("The Agency Entered is not in database, would you like to
add it?", vbYesNo) = vbYes Then
DoCmd.OpenForm "FormName", , , , acFormAdd, acDialog, NewData
Response = acDataErrAdded
End If

Code the "FormName" Load event:
If Not IsNull(Me.OpenArgs) Then
Me.[ControlName] = Me.OpenArgs
End If

The form will open with the newly added data in the field.
You can then continue filling in additional information on this form,
such as Agency address, Phone, Contact name, etc.
When you close this form, you will be back in the original form and
the entry will be in the combo box list.

If you do not really need to open a form to enter the new data into
(because other than the one Item, there is no additional associated
data to fill in) you can use a simple Append query code to add the new
data.

If MsgBox("The Item Entered is not in database, would you like to add
it?", vbYesNo) = vbYes Then
CurrentDb.Execute " INSERT INTO TableName(FieldName) Select " &
Chr(34) & NewData & Chr(34) & ";", dbFailOnError
Response = acDataErrAdded
End If
 
Thank you very much. Each time I come here I am overwhelmed by the wealth of
information all of you supply, and the kindness and patience with which it is
imparted. I am very appreciative of that. Thanks again.
--
Norm Shimmel
Butler, PA


Klatuu said:
Okay, thanks
I would then recommend the method that fredg proposed. That is opening form
in data entry mode and passing the value of the NewData variable to the form
in the OpenArgs argument.

There is one other issue to deal with. That is that the new patient will
not yet be in your prescription form's recordset, so you will have to requery
the form after you have added the new patient. I would suggest you open the
form using acDialog. That will cause the code in the prescription form to
suspend until the patient form is closed. Then, requery the prescription
form. Now, that brings up another issue. When you requery a form, to goes
to the first record in the form' recordset, so you have to save the value of
the primary key of the current record so you can move back to it after the
requery. So it would go something like:

Dim lngPrimeKey As Long

DoCmd.OpenForm "FormName", , , , acFormAdd, acDialog, NewData

lngPrimeKey = Me.txtPrimeKeyControl
Me.Requery
With Me.RecordsetClone
.FindFirst "[PrimeKeyField] = " & lngPrimeKey
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With

Me.TxtSomeControl = NewData
--
Dave Hargis, Microsoft Access MVP


NES said:
Yes, that's correct. The so-called physicians table in fact includes Nurse
Practitioners, and is called the "Professionals table". It contains three
fields: name, specialty (Physician, NP, Dentist, Etc.) and the federal DEA
number. This data is used as historical data and label printing of course. I
just learned that we are NOT filling prescriptions written by outside
physicians, so this aspect is not a problem. But the problem remains for
patients who may not appear in the combo box. That should NOT occur, because
they should be asked if they've received prescriptions before. But you know
how that goes...!

The form for preparing prescriptions is rather more complicated, and in fact
contains 3 sub forms for various reasons. It is not only the primary
prescription form for the table of the same name, but one subform in it takes
care of the details of the original filling and all refills filed in the
Prescription Details table. This table is displayed in a continuous form
within the primary form, and is used to track medications as well as costs
for various reports.

Of course, since this is a relational DB, only the record number for the
patient, physician, and medication, is retained in the primary prescription
table along with instructions, quanty, number of refills allowed, date, etc.

Combo boxes are used to select patient by the last 4 of the social security
number (with confirmation of name) OR by typing in the LAST NAME, FIRST NAME.

Physician is selected by name from a combo box, as is the medication. When
all of this info has been entered into the primary form, entry flow moves to
the details sub form to allow input of what filling or refill it is, the
number actually dispensed (which can differ depending of availability),
auto-date, and then preview and printing of the label.

Refills are a breeze. Enter the prescription number at the top of the form,
and move to the details sub form for one entry (refill #) and accepting the
default number dispensed. Couple of clicks and you have the label and the
record is saved.

Each time that prescription is viewed, you see the entire history of
fillings, running total of fillings, running total of units (tabs, pills,
etc.) dispensed, as well as all the primary info.
--
Norm Shimmel
Butler, PA


Klatuu said:
So you are saying there is a table for physicians and a table for patients
and there are forms for entering data for each of these. Or in the case of
physician, it is only a name? And that the form you are entering data in is
not the form you would be entering patient information in? And, the form you
are working from is a different form where you enter prescription information
for the patient?

--
Dave Hargis, Microsoft Access MVP


:

Thank you so much. I am refining a working application dealing with health
clinic prescription medication distribution. The ideal is that the patient's
data is already in the table and can be selected from a combo box by means of
the last 4 SS digits (with confirmation of name) or by typing the name in a
different combo box.

The selection holds true for the prescribing physician (by name only) who
ordinarily is already employed in the clinic. However, we fill prescriptions
from "outside" physicians as well, and they may or may not be in the
Physicians table.

So unless we check the two tables before begining the prescription entry,
that entry can be a crap shoot. The physician's data is just a name, but the
patient's info includes name, address, phone, etc.

Thanks again.

--
Norm Shimmel
Butler, PA


:

Based on your earlier description of the problem, fredg's code for opening a
data entry form to add the record may be the easiest way to do this. But, If
the form you need to enter the new record in is the form you currently have
open, you would do it a little differently. You would just go to a new
record and populate the appropriate field with the NewData value.
--
Dave Hargis, Microsoft Access MVP


:

Yet another possible solution. Thank you very very much. I'm saving all of
these by the way. I'll check this out too.
--
Norm Shimmel
Butler, PA


:

On Thu, 8 May 2008 06:31:01 -0700, NES wrote:

When filling out a form that has combo boxes, very often I find data is not
yet in the dropdown list. (Data appearing in the list is entered through
another form.)

I've seen that option in the properties list, and I see that it requires the
bound column to show. But then what? I still can't enter data into the "other
form" in order to complete the form I'm working in. I can trigger a jump out
of the current form and display the required input form, but besides not
being very elligant, it wastes an auto-number record number in the original
form. The problem is worse if more than one combo box is involved on the
form.

Any help would be appreciated. Thanks in advance.

If you must open a form to add the new data (it isn't necessary in
most instances), you can code the Combo Box's NotInList event:

If MsgBox("The Agency Entered is not in database, would you like to
add it?", vbYesNo) = vbYes Then
DoCmd.OpenForm "FormName", , , , acFormAdd, acDialog, NewData
Response = acDataErrAdded
End If

Code the "FormName" Load event:
If Not IsNull(Me.OpenArgs) Then
Me.[ControlName] = Me.OpenArgs
End If

The form will open with the newly added data in the field.
You can then continue filling in additional information on this form,
such as Agency address, Phone, Contact name, etc.
When you close this form, you will be back in the original form and
the entry will be in the combo box list.

If you do not really need to open a form to enter the new data into
(because other than the one Item, there is no additional associated
data to fill in) you can use a simple Append query code to add the new
data.

If MsgBox("The Item Entered is not in database, would you like to add
it?", vbYesNo) = vbYes Then
CurrentDb.Execute " INSERT INTO TableName(FieldName) Select " &
Chr(34) & NewData & Chr(34) & ";", dbFailOnError
Response = acDataErrAdded
End If
 
Thanks for the kudos. Everyone here is just like you. We are here to help
each other and share info. I am glad I could help.
--
Dave Hargis, Microsoft Access MVP


NES said:
Thank you very much. Each time I come here I am overwhelmed by the wealth of
information all of you supply, and the kindness and patience with which it is
imparted. I am very appreciative of that. Thanks again.
--
Norm Shimmel
Butler, PA


Klatuu said:
Okay, thanks
I would then recommend the method that fredg proposed. That is opening form
in data entry mode and passing the value of the NewData variable to the form
in the OpenArgs argument.

There is one other issue to deal with. That is that the new patient will
not yet be in your prescription form's recordset, so you will have to requery
the form after you have added the new patient. I would suggest you open the
form using acDialog. That will cause the code in the prescription form to
suspend until the patient form is closed. Then, requery the prescription
form. Now, that brings up another issue. When you requery a form, to goes
to the first record in the form' recordset, so you have to save the value of
the primary key of the current record so you can move back to it after the
requery. So it would go something like:

Dim lngPrimeKey As Long

DoCmd.OpenForm "FormName", , , , acFormAdd, acDialog, NewData

lngPrimeKey = Me.txtPrimeKeyControl
Me.Requery
With Me.RecordsetClone
.FindFirst "[PrimeKeyField] = " & lngPrimeKey
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With

Me.TxtSomeControl = NewData
--
Dave Hargis, Microsoft Access MVP


NES said:
Yes, that's correct. The so-called physicians table in fact includes Nurse
Practitioners, and is called the "Professionals table". It contains three
fields: name, specialty (Physician, NP, Dentist, Etc.) and the federal DEA
number. This data is used as historical data and label printing of course. I
just learned that we are NOT filling prescriptions written by outside
physicians, so this aspect is not a problem. But the problem remains for
patients who may not appear in the combo box. That should NOT occur, because
they should be asked if they've received prescriptions before. But you know
how that goes...!

The form for preparing prescriptions is rather more complicated, and in fact
contains 3 sub forms for various reasons. It is not only the primary
prescription form for the table of the same name, but one subform in it takes
care of the details of the original filling and all refills filed in the
Prescription Details table. This table is displayed in a continuous form
within the primary form, and is used to track medications as well as costs
for various reports.

Of course, since this is a relational DB, only the record number for the
patient, physician, and medication, is retained in the primary prescription
table along with instructions, quanty, number of refills allowed, date, etc.

Combo boxes are used to select patient by the last 4 of the social security
number (with confirmation of name) OR by typing in the LAST NAME, FIRST NAME.

Physician is selected by name from a combo box, as is the medication. When
all of this info has been entered into the primary form, entry flow moves to
the details sub form to allow input of what filling or refill it is, the
number actually dispensed (which can differ depending of availability),
auto-date, and then preview and printing of the label.

Refills are a breeze. Enter the prescription number at the top of the form,
and move to the details sub form for one entry (refill #) and accepting the
default number dispensed. Couple of clicks and you have the label and the
record is saved.

Each time that prescription is viewed, you see the entire history of
fillings, running total of fillings, running total of units (tabs, pills,
etc.) dispensed, as well as all the primary info.
--
Norm Shimmel
Butler, PA


:

So you are saying there is a table for physicians and a table for patients
and there are forms for entering data for each of these. Or in the case of
physician, it is only a name? And that the form you are entering data in is
not the form you would be entering patient information in? And, the form you
are working from is a different form where you enter prescription information
for the patient?

--
Dave Hargis, Microsoft Access MVP


:

Thank you so much. I am refining a working application dealing with health
clinic prescription medication distribution. The ideal is that the patient's
data is already in the table and can be selected from a combo box by means of
the last 4 SS digits (with confirmation of name) or by typing the name in a
different combo box.

The selection holds true for the prescribing physician (by name only) who
ordinarily is already employed in the clinic. However, we fill prescriptions
from "outside" physicians as well, and they may or may not be in the
Physicians table.

So unless we check the two tables before begining the prescription entry,
that entry can be a crap shoot. The physician's data is just a name, but the
patient's info includes name, address, phone, etc.

Thanks again.

--
Norm Shimmel
Butler, PA


:

Based on your earlier description of the problem, fredg's code for opening a
data entry form to add the record may be the easiest way to do this. But, If
the form you need to enter the new record in is the form you currently have
open, you would do it a little differently. You would just go to a new
record and populate the appropriate field with the NewData value.
--
Dave Hargis, Microsoft Access MVP


:

Yet another possible solution. Thank you very very much. I'm saving all of
these by the way. I'll check this out too.
--
Norm Shimmel
Butler, PA


:

On Thu, 8 May 2008 06:31:01 -0700, NES wrote:

When filling out a form that has combo boxes, very often I find data is not
yet in the dropdown list. (Data appearing in the list is entered through
another form.)

I've seen that option in the properties list, and I see that it requires the
bound column to show. But then what? I still can't enter data into the "other
form" in order to complete the form I'm working in. I can trigger a jump out
of the current form and display the required input form, but besides not
being very elligant, it wastes an auto-number record number in the original
form. The problem is worse if more than one combo box is involved on the
form.

Any help would be appreciated. Thanks in advance.

If you must open a form to add the new data (it isn't necessary in
most instances), you can code the Combo Box's NotInList event:

If MsgBox("The Agency Entered is not in database, would you like to
add it?", vbYesNo) = vbYes Then
DoCmd.OpenForm "FormName", , , , acFormAdd, acDialog, NewData
Response = acDataErrAdded
End If

Code the "FormName" Load event:
If Not IsNull(Me.OpenArgs) Then
Me.[ControlName] = Me.OpenArgs
End If

The form will open with the newly added data in the field.
You can then continue filling in additional information on this form,
such as Agency address, Phone, Contact name, etc.
When you close this form, you will be back in the original form and
the entry will be in the combo box list.

If you do not really need to open a form to enter the new data into
(because other than the one Item, there is no additional associated
data to fill in) you can use a simple Append query code to add the new
data.

If MsgBox("The Item Entered is not in database, would you like to add
it?", vbYesNo) = vbYes Then
CurrentDb.Execute " INSERT INTO TableName(FieldName) Select " &
Chr(34) & NewData & Chr(34) & ";", dbFailOnError
Response = acDataErrAdded
End If
 
Back
Top