Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / April 2008

Tip: Looking for answers? Try searching our database.

Need Help with Code (included in message)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Such a Beginner - 11 Apr 2008 22:57 GMT
My Unbound Combo Box is a dropdown list of Anthocyanins, Liver Lipids,
Plasma, and ORAC.  The code below always results in the first DoCmd statement
being executed.  In other words, if I update the Unbound box with any word
from the above list, I get the same result.  Could someone please diagnose my
code problem (see below)?

Private Sub Combo0_AfterUpdate()
If Unbound = Anthocyanins Then
DoCmd.OpenForm "frmAnthocyanins", acNormal
ElseIf Unbound = Liver_Lipids Then
DoCmd.OpenForm "frmLiverLipids", acNormal
ElseIf Unbound = Plasma Then
DoCmd.OpenForm "frmPlasma", acNormal
ElseIf Unbound = ORAC Then
DoCmd.OpenForm "frmORAC", acNormal
End If

End Sub
Clif McIrvin - 12 Apr 2008 00:05 GMT
I think this is one I can answer ... so I'll give it a go.  This
information comes from the Access VB help for Combo Box Object; then
look at the Value property.

In general, to get the value that belongs to a combo box use
the .Value property when referring to it (I'll edit your code sample
in a minute) _but_ there are exceptions to that -- that's why I refer
you to the help file.

I think your code needs to look like this (indents added to assist in
seeing what the IF statements are doing:)

Private Sub Combo0_AfterUpdate()
  If Me.Combo0.Value = "Anthocyanins" Then
     DoCmd.OpenForm "frmAnthocyanins", acNormal
  ElseIf Me.Combo0.Value= "Liver Lipids" Then
     DoCmd.OpenForm "frmLiverLipids", acNormal
  ElseIf Me.Combo0.Value= "Plasma" Then
     DoCmd.OpenForm "frmPlasma", acNormal
  ElseIf Me.Combo0.Value= "ORAC" Then
     DoCmd.OpenForm "frmORAC", acNormal
  End If
End Sub

Note that I didn't use your variable "Unbound" -- I have no idea what
it means, and Me.Combo0.Value refers to the combo box that this
procedure was called by.

Also note that I used double quotes ( " ) to tell the VB compiler that
Anthocyanins, Liver Lipids, Plasma, and ORAC are constants (that is,
actual values), not variable names.

HTH

--
Clif

On Apr 11, 4:57 pm, Such a Beginner
<SuchaBegin...@discussions.microsoft.com> wrote:
> My Unbound Combo Box is a dropdown list of Anthocyanins, Liver Lipids,
> Plasma, and ORAC.  The code below always results in the first DoCmd statement
[quoted text clipped - 14 lines]
>
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.