Hi
I am unsure how to code the following
the table I am working on is Baan
I am selecting the record using the orderNo field
but depending if the field IcyDate empty or not I will open different forms
the code I have in the event call at the moment is below and where I have
put the ***** is where I need an if statement to see if the field IcyDate is
empty or not
Private Sub But_SelONo_Click()
On Error GoTo Err_But_SelONo_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim intcount As Integer
intcount = DLookup("[Count-O-N]", "[Qu-cmm-countorders2]") ' the query
this refers to counts the number of orders there are against this order no
If intcount = 0 Then
MsgBox "Not a valid order No: or no order No entered." & " Please re
enter." 'If there are none it displays a message box
ElseIf intcount = 1 Then
*****
stDocName = "CmmBaanEntry"
stLinkCriteria = "[OrderNo]=" & Me![Txt_reqONo]
DoCmd.OpenForm stDocName, , , stLinkCriteria
If dateIcyBaan = VBA.date() Then
End If
DoCmd.Close acForm, "fr-cmm-select-order" ' if there is one
it will open the baan form with the oder loaded
ElseIf intcount > 1 Then ' if there is more
than 1 oder it opens a list of oders so the correct order can be selected
stDocName = "Frm-cmm-Select-stage"
stLinkCriteria = "[OrderNo]=" & Me![Txt_reqONo]
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "fr-cmm-select-order"
End If
Exit_But_SelONo_Click:
Exit Sub
Err_But_SelONo_Click:
MsgBox Err.Description
Resume Exit_But_SelONo_Click
End Sub
Thanks
Jon
Arvin Meyer [MVP] - 14 Jan 2008 04:50 GMT
What doesn't work?
From what I can see, the only thing immediately obvious is that you don't
tell the DLookup code what [Order No] to count on., But that may read it
from the form when it is opened.

Signature
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
> Hi
>
[quoted text clipped - 55 lines]
>
> Jon
jon - 14 Jan 2008 05:28 GMT
Sorry I need a new if statement within the code I have where I put the *****
so if the icydate field is empty/null it opens one form, and if has a dete
it that feild opens the form I have already in the code.
ta Jon
Arvin Meyer [MVP] - 14 Jan 2008 15:16 GMT
I'd use a Select Case statement, but you can continue with the code you
have. To test for null, just wrap the code you want to use for that form in
the following:
If Len([Me.[Txt_reqONo] & vbNullString) = 0 Then
' Do something
Else
' Do something else
End If
using vbNullString as a constant, takes care of either Null or Empty.

Signature
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
> Sorry I need a new if statement within the code I have where I put the
> *****
> so if the icydate field is empty/null it opens one form, and if has a dete
> it that feild opens the form I have already in the code.
>
> ta Jon