**anywhere you see the word BANANA, I really meant e-m-a-i-l. Apparently I can't post e-m-a-i-l addresses because I haven't posted 10 times** Lets disregard the fact that there isn't a single @ in this post (well, there is now!)
I have a form with two list boxes on it: listAllBANANA and listActiveBANANA
The listboxes are populated from tblBANANA. Active is defined by the tblBANANA field "ResponseDate" being Null.
Also on the form is a CloseBANANA command button. When pressed with no selection, it opens frmCloseBANANA to the first record. If a BANANA is selected in listActiveBANANA, the form opens to the selected record.
Now comes the tricky part: if a BANANA is selected in listAllBANANA, I first need to verify they have an Active BANANA selected, before opening the form. I've poked and tested and searched and cut and pasted my little fingers off with no joy. What I've deduced is that I'm either messing up the syntax of the DLookup or I'm incorrectly referencing the selected record. There's also the third option that I'm going about this in entirely the wrong way.
All other code below works. If I delete or comment out the line in red, I have no issues other than I may open up a blank form because I'm trying to close a BANANA that is already closed.
help?
I have a form with two list boxes on it: listAllBANANA and listActiveBANANA
The listboxes are populated from tblBANANA. Active is defined by the tblBANANA field "ResponseDate" being Null.
Also on the form is a CloseBANANA command button. When pressed with no selection, it opens frmCloseBANANA to the first record. If a BANANA is selected in listActiveBANANA, the form opens to the selected record.
Now comes the tricky part: if a BANANA is selected in listAllBANANA, I first need to verify they have an Active BANANA selected, before opening the form. I've poked and tested and searched and cut and pasted my little fingers off with no joy. What I've deduced is that I'm either messing up the syntax of the DLookup or I'm incorrectly referencing the selected record. There's also the third option that I'm going about this in entirely the wrong way.
All other code below works. If I delete or comment out the line in red, I have no issues other than I may open up a blank form because I'm trying to close a BANANA that is already closed.
Code:
'If a BANANA is selected in Active BANANA or All BANANA, open Close BANANA to that record. If not, open form to most recent record
Private Sub cmdCloseBANANA_Click()
If Not IsNull(Forms!frmGUI!listActiveBANANA) Then
DoCmd.OpenForm "frmCloseBANANA", acNormal, , "[BANANAID] = " & Forms!frmGUI!listActiveBANANA.Column(0) & ""
ElseIf Not IsNull(Forms!frmGUI!listAllBANANA) Then
'Make sure selected BANANA is Active
If [COLOR="Red"]IsNull(DLookup(ResponseDate, tblBANANA, "[BANANAID] = " & Forms!frmGUI!listAllBANANA.Column(0) & ""))[/COLOR] Then
DoCmd.OpenForm "frmCloseBANANA", acNormal, , "[BANANAID] = " & Forms!frmGUI!listAllBANANA.Column(0) & ""
Else: msgbox "The selected BANANA is already closed. Please choose an Active BANANA.", vbOKOnly + vbCritical, "Invalid Selection"
End If
Else: DoCmd.OpenForm "frmCloseBANANA"
End If
End Sub
help?