Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Modify VBA routine to pass Form combo box value into Tbl created by event procedure

Modify VBA routine to pass Form combo box value into Tbl created by event procedure

Modify VBA routine to pass Form combo box value into Tbl created by event procedure

I have a form which allows the user to select a drop down filter for several roles in a company (think SVP, VP, ect.) After user clicks a the Combo box filter and selects a name within the values list, a VBA procedure is run that creates a [propertytbl] containing all properties and there parameters associated with that person. Along with the properties and associated parameters in a table called I want a field (call it Role) in [PropertyTbl] table which will contain the persons name we selected using the combo box value named - cboEVPOName. Any ideas on how to modify this procedure to achieve desired result? Thank you in advance.

Private Sub cboEVPOName_AfterUpdate()

Me.cboDivisionName = vbNullString
Me.cboRegionName = vbNullString
Me.cboPropertyName = vbNullString

Me.cboEVPSName = vbNullString

Me.cboEVPFName = vbNullString

Me.cboSVPRMName = vbNullString

Me.cboSVPOName = vbNullString

Me.cboVPOName = vbNullString

Me.cboSVPSName = vbNullString

Me.cboVPSName = vbNullString

Me.cboVPFName = vbNullString

Me.cboRDRMName = vbNullString

Me.cboADRMName = vbNullString

DoCmd.SetWarnings False

Dim pmDelete As String
pmDelete = ""
pmDelete = pmDelete & "Delete * from PropertyTbl;"

DoCmd.RunSQL pmDelete

Dim db As Database
Dim qdf As QueryDef
Dim tbl As TableDef

Set db = CurrentDb()
Set qdf = db.QueryDefs("qdf")

Dim strProperty As String

strProperty = Forms![checkmax]!cboEVPOName

Dim StrSQL As String

StrSQL = ""

StrSQL = StrSQL & " SELECT Property.PropertyCode,"
StrSQL = StrSQL & " Property.PropertyName, "
StrSQL = StrSQL & " Property.Region, "
StrSQL = StrSQL & " Property.RegionName, "
StrSQL = StrSQL & " Property.Division, Property.DivisionName, "
StrSQL = StrSQL & " Property.EVPO, "
StrSQL = StrSQL & " Property.EVPS, "
StrSQL = StrSQL & " Property.EVPF, "
StrSQL = StrSQL & " Property.SVPRM, "
StrSQL = StrSQL & " Property.HR, "
StrSQL = StrSQL & " Property.VPF, "
StrSQL = StrSQL & " Property.RDRM, "
StrSQL = StrSQL & " Property.ADRM, "
StrSQL = StrSQL & " Property.SVPS, "
StrSQL = StrSQL & " Property.VPS, "
StrSQL = StrSQL & " Property.VPO, "
StrSQL = StrSQL & " Property.AGM, "
StrSQL = StrSQL & " Property.SVPO, "
StrSQL = StrSQL & " Property.GM, "
StrSQL = StrSQL & " Property.Portfolio "
StrSQL = StrSQL & " INTO PropertyTbl "
StrSQL = StrSQL & " FROM Property "
StrSQL = StrSQL & " WHERE (((Property.EVPO) "
StrSQL = StrSQL & " =[forms]![checkmax].[cboEVPOName]));"

Debug.Print StrSQL

qdf.SQL = StrSQL

DoCmd.SetWarnings False

DoCmd.OpenQuery "qdf"

DoCmd.SetWarnings True

End Sub

RE: Modify VBA routine to pass Form combo box value into Tbl created by event procedure

I think I solved my own question for Once. By adding this code before my End sub statement I get the intended result:

'UPDATE PropertyTbl SET PropertyTbl.Portfolio = [Forms]![checkmax]![cboEVPOName];

DoCmd.SetWarnings False

Dim pmUpdate As String
pmUpdate = ""
pmUpdate = pmUpdate & "UPDATE PropertyTbl SET PropertyTbl.Portfolio = [Forms]![checkmax]![cboEVPOName];"

DoCmd.RunSQL pmUpdate

End Sub

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close