Hi RuralGuy, Hope you had a good weekend -
Okay, let's see if I can clear up a couple of the ambiguties I have created
in my previous explanation.
There is only one form involved. It is derived from the table "Table1
which has five fields in it (Field 1 through Field4) and the ContractorName
field which is also in Table1. As I mentioned in my previous post, the "Row
Source" for the ContractorName field on the form is "SELECT
[tblContractors].[ContractorName] FROM tblContractors;". Also the RowSource
Type is Table/Query. Is this a correct reference for this field?
I may not be doing this properly, but I have done it this way before. (the
reference from the 2 tables to create a form). I have the relationship for
the 2 tables linked with the ContractorName field.
In looking over your suggestion, it looks like I will have to add another
field to the tblContractors and that would be an AutoNumber field. This will
be called the Contractor ID field. There may be 10 contractors, and they
would have an ID of 1-10. If a new contractor is called for, we would be
sent to another form to enter the new ContractorName, and the updated ID
field would be self generated by the AutoNumber. Upon exit from entering the
new ContractorName into the tblContractors, I would return to the Form1, and
the new ContractorName would now be in the tblContractors so the error would
not occur. I assume that I would return back to the ContractorName field on
Form1. ??
To clarify a couple things I'm not sure of, to get to the new form to enter
the new ContractorName, I could have a macro on the NotInList property that
would open the new form to add the new ContractorName. After entering the
new name, then I could have an "exit" button on this form that would take me
back to Form1, and position me at the field to enter the requested
ContractorName, which would now be there because we just put it in the table.
Would I have to do any kind of "reset" to get past the error I got earlier
when the ContractorName I was asking for was not there?
You mentioned putting the Contractor ID number in the
WorkOrder![Contractor]. Why would we put the contractor ID in the work
Order, and not the contractor Name? In fact, why do we need a Contractoir ID
in the first place? Can't we just add the new ContractorName to the
tblContractors (while we're at the form that accepts the new Contractor
names) so it will be recognized when we return to Form1 to re-enter the new
ContractorName? Please explain the need for the Contractor ID.
Please have patience with my limitations, because I would hate to lose your
input.
10SNUT
10SNUT
Hi RuralGuy,
I will try to answer all your questions.
1. The routine is a simple "test" routine to get this function
working. It wil be used in a larger application when I get it
working. 2. There is nothing secretive about the data in the "test"
routine, as well as the larger routine, but I thought a simple routine
would make it simpler to diagnose.
3. The response is actually the data I tried to enter into the combo
box, in this case, the number "4".
4. The sequence of events is as follows : The form has 4 other
fields, and I enter data into them - no problem. Then I get to the
combo box field, and I try to enter a "4". The underlying table,
"tblContractors" has only one entry, and it is "1 Contractor". When I
enter the "4", I get the error response that's in my routine: "Do you
want to add '4' to the list of contractors?", and there is a "OK" and
a "Cancel" button on the question box.
I hit the "OK" button, and I get the diagnostic error response "(4)
is NOT
in the Table yet!" with an "OK" button. I hit the "OK" button, and
then I get the system generated error: "The text you entered is not an
item in the list. Select an item from the list, or enter text that
matches one of the listed items." with an "OK" button. If I hit the
"OK" button, I get the original form displayed with the number "4" in
the ContractorName field, and below that, There is a box with the only
entry in the tblContractors table, "1 Contractor". There is an "EXIT"
button on the form. If I hit it, the form closes.
5. All entries on the "Form1" are simply entries dragged from the
table list while the form is in Design mode. The ContractorName box
was created by using the "ComboBox" button in the Form menu. The
properties of the ContractName field are: Both the Name and Control
Source are "ContractorName". The Row source is "SELECT
[tblContractors].[ContractorName] FROM tblContractors;. The RowSource
Type is Table/Query.
6. All fields on the form are text fields with the std. length of 50
characters. All fields are bound to the tblContractors table.
7. I'm using Access 2000, version (9.0 4402 SR-1).
That covers about all you asked. The actual application I use is only
about 370KB. Is there any way to send that to you without giving out
my actual email address?
Hope this helps in the resolution. Thanks again.
10SNUT.
Hi 10SNUT,
I had to read this about 6 time until the light bulb went off!!!!
Correct me if I'm wrong but I think there is only one form involved here
and it is named "Form1". If you want to add a "New Contractor" you are
recursively calling "Form1" again.
Forgive me if I am conveying information you already know, but there is
such a long turn around time between postings that I want to pass as much
information with each post as possible.
ComboBoxes are for looking up existing data or in our case providing both
the look up feature along with the ability to add additional records. In
either case the "AfterUpdate" event of this ComboBox would have code to
move the record pointer to the record containing the field that matches
what we just selected.
----------------------------------------------------
Something like this UNTESTED AirCode:
Private Sub Contractor_AfterUpdate()
DoCmd.Requery ' Get any changes to the table first.
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[ContractorName] = " & Me.Contractor.Column(0)
If Not Me.RecordsetClone.EOF Then
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
End Sub
----------------------------------------------------
Normally you would use a ComboBox to place an ID number of some sort in
another table. In our example let's say we were issuing a purchase order
for some work to be accomplished. The form is bound to our WorkOrder
table. The Contractor table "tblContractors" describes each contractor and
has a ContractorID field that is a AutoNumber field. We have fields on our
form that completely describe the work to be accomplished along with a
ComboBox to select the Contractor.
Without going into too much detail here (which I would be glad to do if you
wish to go there) we set up our ComboBox the same way as we have in your
case. If we type in a completely new contractor and we want to add them to
our system, we are taken to a completely new form where we can define this
contractor properly and this contractor is added to the "tblContractors"
table. When we get back from adding the contractor the bound column of
this ComboBox will put the ContractoID number in our WorkOrder![Contractor]
field.
I hope I haven't bored you to death with stuff you already knew. If I
have, maybe someone else reading this thread didn't look at ComboBoxes this
way and found some useful information.
Does any of this make any sense to you? Am I on the right track as to how
your form is working?
Post back and I'll adjust direction as needed.
--
RuralGuy
Please reply to the newsgroup so all may benefit.
6. All fields on the form are text fields with the std. length of 50
characters. All fields are bound to the tblContractors table.
7. I'm using Access 2000, version (9.0 4402 SR-1).
That covers about all you asked. The actual application I use is only
about 370KB. Is there any way to send that to you without giving out
my actual email address?
Hope this helps in the resolution. Thanks again.
10SNUT.
Hi 10SNUT,
I had to read this about 6 time until the light bulb went off!!!!
Correct me if I'm wrong but I think there is only one form involved here
and it is named "Form1". If you want to add a "New Contractor" you are
recursively calling "Form1" again.
Forgive me if I am conveying information you already know, but there is
such a long turn around time between postings that I want to pass as much
information with each post as possible.
ComboBoxes are for looking up existing data or in our case providing both
the look up feature along with the ability to add additional records. In
either case the "AfterUpdate" event of this ComboBox would have code to
move the record pointer to the record containing the field that matches
what we just selected.
----------------------------------------------------
Something like this UNTESTED AirCode:
Private Sub Contractor_AfterUpdate()
DoCmd.Requery ' Get any changes to the table first.
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[ContractorName] = " & Me.Contractor.Column(0)
If Not Me.RecordsetClone.EOF Then
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
End Sub
----------------------------------------------------
Normally you would use a ComboBox to place an ID number of some sort in
another table. In our example let's say we were issuing a purchase order
for some work to be accomplished. The form is bound to our WorkOrder
table. The Contractor table "tblContractors" describes each contractor and
has a ContractorID field that is a AutoNumber field. We have fields on our
form that completely describe the work to be accomplished along with a
ComboBox to select the Contractor.
Without going into too much detail here (which I would be glad to do if you
wish to go there) we set up our ComboBox the same way as we have in your
case. If we type in a completely new contractor and we want to add them to
our system, we are taken to a completely new form where we can define this
contractor properly and this contractor is added to the "tblContractors"
table. When we get back from adding the contractor the bound column of
this ComboBox will put the ContractoID number in our WorkOrder![Contractor]
field.
I hope I haven't bored you to death with stuff you already knew. If I
have, maybe someone else reading this thread didn't look at ComboBoxes this
way and found some useful information.
Does any of this make any sense to you? Am I on the right track as to how
your form is working?
Post back and I'll adjust direction as needed.