Autopopulate in form

  • Thread starter Thread starter teelee
  • Start date Start date
T

teelee

I was wondering if you could give me some advice on this problem
I'm having. I have a plan number on my form that I would like to enter the
number and have the plan name and other info related to the plan number
automatically populate after the plan number is entered. I tried this code
but it didn't work this is what I have on the after update:
Me.filter = "[plannumber] = """ & Me.combo & """"
Me.filteron = true

Thanks in advance
 
I was wondering if you could give me some advice on this problem
I'm having. I have a plan number on my form that I would like to enter the
number and have the plan name and other info related to the plan number
automatically populate after the plan number is entered. I tried this code
but it didn't work this is what I have on the after update:
Me.filter = "[plannumber] = """ & Me.combo & """"
Me.filteron = true

Thanks in advance

If you're trying to find and display an existing record in the form's table,
use an unbound Combo Box. The Combo Box wizard on the toolbar will set this up
for you - "use this combo to find a record".

If you're trying to copy the plan data from one table and store it in a
different table... *don't*. Storing data redundantly is neither necessary nor
appropriate.
 
John,

I have the same issue. I followed your directions, however, when I select a
record for the new combo box the other fields do not change to the record I
selected.

John W. Vinson said:
I was wondering if you could give me some advice on this problem
I'm having. I have a plan number on my form that I would like to enter the
number and have the plan name and other info related to the plan number
automatically populate after the plan number is entered. I tried this code
but it didn't work this is what I have on the after update:
Me.filter = "[plannumber] = """ & Me.combo & """"
Me.filteron = true

Thanks in advance

If you're trying to find and display an existing record in the form's table,
use an unbound Combo Box. The Combo Box wizard on the toolbar will set this up
for you - "use this combo to find a record".

If you're trying to copy the plan data from one table and store it in a
different table... *don't*. Storing data redundantly is neither necessary nor
appropriate.
 
John,

I have the same issue. I followed your directions, however, when I select a
record for the new combo box the other fields do not change to the record I
selected.

Then there's something wrong. If you would like help fixing it, please post
enough details that someone might have a chance to help:

- The Rowsource and Bound Column properties of the combo (post the SQL if it's
a query)
- The Recordsource 0f the form (post the SQL)
- The AfterUpdate event code of the combo
 
This is the code that I'm using: Me.filter = "[plannumber] = """ & Me.combo &
""""
Me.filteron = true What I'm trying to do is once I enter the Plan Number I
would like for the Plan Name field along with any realted info fields to
autopopulate. This would be done in the form.

Thanks
 
This is the code that I'm using: Me.filter = "[plannumber] = """ & Me.combo &
""""
Me.filteron = true What I'm trying to do is once I enter the Plan Number I
would like for the Plan Name field along with any realted info fields to
autopopulate. This would be done in the form.

Setting the filter won't do anything except *hide* data. It certainly won't
bring up a record which is not already there!

Try deleting the code and the combo box, and using the Toolbox Combo Box
wizard to create a new combo. Use the option "Use this combo to find a
record".
 
ok you see I don't want to have the plan number in a combo box, I want to
enter the plan number in myself then have the plan name and other related
info to automatically fill in. On my form I have a Plan Number, Plan Name,
Old Plan Name.

Thanks

John W. Vinson said:
This is the code that I'm using: Me.filter = "[plannumber] = """ & Me.combo &
""""
Me.filteron = true What I'm trying to do is once I enter the Plan Number I
would like for the Plan Name field along with any realted info fields to
autopopulate. This would be done in the form.

Setting the filter won't do anything except *hide* data. It certainly won't
bring up a record which is not already there!

Try deleting the code and the combo box, and using the Toolbox Combo Box
wizard to create a new combo. Use the option "Use this combo to find a
record".
 
ok you see I don't want to have the plan number in a combo box, I want to
enter the plan number in myself then have the plan name and other related
info to automatically fill in. On my form I have a Plan Number, Plan Name,
Old Plan Name.

By "fill in" do you mean:

- Navigate the form to display an existing record for this plan? (good, see
below)
- Copy the Plan Name and Old Plan Name from an existing Plan table and store
them redundantly in some other table? (BAD idea).

If the former, try the following code in the textbox's AfterUpdate event:

Private Sub txtPlanNumber_AfterUpdate()
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone ' get the form's recordsource
rs.FindFirst "[Plan Number] = " & Me!txtPlanNumber
If rs.NoMatch Then
MsgBox "This plan does not seem to exist, moving to new record"
DoCmd.GoToRecord acDataForm, Me.Name, acNewRecord
Else
Me.Bookmark = rs.Bookmark ' jump to the found record
End If
Set rs = Nothing
End Sub


If the datatype of Plan Number is Text rather than Number you'll need some
quotemarks:

rs.FindFirst "[Plan Number] = '" & Me!txtPlanNumber & "'"

For readability (don't do it this way) that's

rs.FindFirst "[Plan Number] = ' " & Me!txtPlanNumber & " ' "

I'm a bit perplexed why you want to be able to enter job numbers (with the
risk of typos, and the lack of autocomplete) rather than just selecting them
from a combo, but that's your choice!
 
Back
Top