Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

After Update Help

Status
Not open for further replies.

Zonie32

Technical User
Jan 13, 2004
242
US
I have a form PremRec. There are 2 fields, Policy# and CoName. I have this bit of code to auto fill the CoName when the Policy# is selected from the drop down on the form.

Private Sub Policy__AfterUpdate()
Dim GroupName As String
GroupName = [Forms]![PremRec]![Policy#].Column(1)
[Forms]!PremRec!CoName = GroupName

End Sub

Now I want to do the same After Update code for the CoName field, so when they choose a CoName from this field it autofills the Policy#. I can't figure out how to write this up. Can anyone help? Thanks for looking!
 
well, this code works fine for the Policy, but I try changing a few things to get the CoName field to work the same way and I just can't get the right words in the right places. I try this and nothing happens.

Private Sub CoName__AfterUpdate()
Dim GroupName As String
Policy# = [Forms]![PremRec]![CoName].Column(1)
[Forms]!PremRec!Policy# = GroupName
 
The policy# is not a key field. I inherited this db from someone who created it years ago. I was asked if I could make this 'little fix' to this form to auto fill the policy number when the user selects the CoName from the drop down. This database is quite complex. Whoever did this spent a lot of time on it, but i'm not sure they knew what they were doing. it's quite a messy db.
 
How are ya Zonie32 . . .

Set the [blue]RowSource[/blue] of the combobox to include both fields and just update both:
Code:
[blue]   Me!CoName = Me![[purple][B][I]ComboboxName[/I][/B][/purple]].Column(1)
   Me!Policy# = Me![[purple][B][I]ComboboxName[/I][/B][/purple]].Column([purple][b]?[/b][/purple])[/blue]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top