Listbox Value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a main form frmPolicyEntry where new records are added using a
combobox with TaxID. My problem is not all of our paperwork will have SSN or
EIN so the user would need to take time to find it.

I currently have a search form where the user can search for existing
records, and was wanting to use a copy of the search form to find the name,
click the record in the listbox and carry the TaxID value over thereby
creaeting a new record. This sounds awful easy, but I seem to be (well I am
no doubt) screwing things up.

My code on the afterupdate() of search form:
DoCmd.OpenForm "frmPolicyEntry", , , "tblPolicy.[TaxID] = " &
lstResults.Column(0), , acDialog, Me!lstResults.Column(0)
DoCmd.Close

My beforeupdate() frmPolicyEntry:
If IsNull(Me.tblPolicy_TaxID) Then
Me.tblPolicy_TaxID = Forms!frmFilterExample5!lstResults.Column(0)
End If

I would appreciate any help or assitance anyone may offer. I have searched
several forums but havent been able to find this instance.

Thanks
g28dman
 
I'm not really following what you are doing. The "Search Form" is
supposed to open frmPolicyEntry after they select a value from the
list box? If so some questions/pointers...

1) Is search form bound to something? If not the I don't think the
AfterUpdate fires for the form, so that code likely won't run.
2) The OpenForm part of the first sub dose not look like it opens the
form to a new record (unles the other form's code handles that after
it's open) if that's the intent. It may bring you to an existing
record, but I'm not sure what it would do when it can't find a match.
3) Putting the DoCmd.Close immediately following the OpenForm method
will close the form you just opened. If you intend to close the search
form you should name it as one of the arguments
4) In the second sub, if you are refering to the search form, then it
may not work depending on what form you were trying to close in #3
question.
 
The search form is currently unbound. It works fine using this in the
afterupdate filtering any records whos TaxId match that of column 0.

DoCmd.OpenForm "frmPolicyEntry", , , "tblPolicy.[TaxID] = " &
lstResults.Column(0), , acDialog, ---->Excluding--->Me!lstResults.Column(0)

I am now just wanting to change the VB code to throw that column 0 value row
value to the combo box on the frmPolicyEntry so that the user does not need
to know the actual tax #, just search for a name, click adding the taxid to
frmPolicyEntry.
 
Back
Top