switching between forms

huskies

Registered User.
Local time
Today, 02:25
Joined
Dec 2, 2008
Messages
25
Here is my situation..
I have a form(1) with various combo and list boxes and a cancel and OK button. One of the list boxes has code written where depending on a name combo box it will read Yes or No. When I click OK if that list box reads Yes I want another form that I have created to present itself.. If the list box contains a No then I want nothing to happen. I have messed around in the expression builder a bit and cant seem to find my answer. Please help!! Thanks!
 
Code:
If Me.ListBoxName = "Yes" Then
  DoCmd.OpenForm...
End If
 
here is what I tried and it did not work...

Private Sub cmdOK_Click()
If Me.lstReloc = "Yes" Then
DoCmd.OpenForm "Relocation", acNormal

End If

End Sub

*I also tried it w/o acNormal.. thoughts? Thank you again
 
Define "did not work".
 
what is "lstreloc"

is it a textbox containing the word "yes", or something else

if something else, then the code wont work
 
The second form did not open up when I finished that code. And no, the list box contains a code that loads either Yes or No from my master table depending on the name of an individual.
 
Well, you have to test for whatever is contained in the bound column of the listbox. Is that "Yes" or a code? Is the listbox multiselect?
 
The list box has a code stating that it will contain either a yes, or no answer from my master table depending on another combo box which is labeled associates Name.. the code I am putting into my OK button is that if the list box pops up yes then to open that form.. I see what you are saying that it could be affected by the list box code, but don't really know where to go from there? any suggestions? Here is what I am putting in as code.. thought it should work? (lstReloc is the name of the list box and Relocation is the name of my 2nd form)

Private Sub cmdOK_Click()

If Me.lstReloc = Yes Then
DoCmd.OpenForm "Relocation", acNormal, acEdit
End If

End Sub

When I click ok nothing happens at all, my first form just simply stays in front of me.. Thoughts?! Thank you
 
What is the rowsource of the listbox (either the SQL or item list)? What is the bound column?
 
Here is the rowsource of the listbox.. SELECT DISTINCT [Recoverables Main].[Relocation] FROM [Recoverables Main] ORDER BY [Relocation];

I have no events contained in the listbox.. my code in the combobox(name) is..
Private Sub cboName_AfterUpdate()
On Error Resume Next
lstReloc.RowSource = "SELECT DISTINCT[Recoverables Main].[Relocation] " & _
"FROM [Recoverables Main] " & _
"WHERE [Recoverables Main].[Associate] = '" & cboName.Value & "' " & _
"ORDER BY [Recoverables Main].[Relocation];"
 
Exactly what values would be contained in the Relocation field? Would it be "Yes", or something else?
 
Then that code should work. Is this 2007, and if so is other code running? Is the code properly associated with the button (do you see "Event Procedure" in the click event in the button's properties, and if so does clicking on the ellipsis take you to that code)? Can you post a sample db?
 
Its not letting me upload the file.. I was able to get it to work if i write the code for afterupdate in the listbox events.. but I need it in the OK button on click events.. any ideas? or ideas on how to load it to show you?
 
That appears to be on your desktop rather than uploaded to the site.
 
ya i zipped my file and it is still saying invalid file
 
Try this right after the line setting the rowsource:

Me.lstReloc.Selected(0) = True

What do you mean the line right after the line setting rowsource? I dont understand sorry.. I have code in my row source for this list box right now..
 

Users who are viewing this thread

Back
Top Bottom