Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VB module question (access 2003)

    I use the code below on a search form to genrate the source of a report. I was trying to add the variable as siteype but it failed. Any idea what is wrong? Thanks..

    Dim like_flag As Boolean
    Dim datStart As Date
    Dim datend As Date
    Dim temp_closed As String

    Dim strwhere As String

    On Error GoTo ErrHandler

    If Not IsNull(Me.SiteID) Then

    If Mid(Me.SiteID, Len(Me.SiteID), 1) = "*" Then
    like_flag = True
    End If

    If like_flag Then
    If Me.SiteID = "APC*" Then
    strwhere = strwhere & "SiteID Like 'O*' OR " & _
    "(SiteID Like 'I*' AND SiteID NOT LIKE 'IT*')OR " & _
    "(SiteID Like 'S*' AND SiteID NOT LIKE 'STN*' ) AND "
    ElseIf Me.SiteID = "S*" Then
    strwhere = strwhere & "(SiteID Like 'S*' AND SiteID NOT LIKE 'STN*' ) AND "
    ElseIf Me.SiteID = "I*" Then
    strwhere = strwhere & "(SiteID Like 'I*' AND SiteID NOT LIKE 'IT*' ) AND "
    Else
    strwhere = strwhere & "SiteID Like '" & Me.SiteID & "' AND"
    End If
    Else
    strwhere = strwhere & "SiteID = '" & Me.SiteID & "' AND"

    End If
    End If


    If Not IsNull(Me.txtTestDate) Then
    If Not IsNull(Me.txtTestDate2) Then
    datStart = CDate(Me.txtTestDate)
    datend = CDate(Me.txtTestDate2)
    ' datend = CDate(Me.txtCreatedOn2)
    ' strwhere = strwhere & " EIRELCTIRR_qry.CreatedOn between #" & datStart & "# And #" & datend & "# AND"
    strwhere = strwhere & " NSReschedules_qry.TestDate between #" & datStart & "# And " & _
    " #" & datend & "# AND"

    Else
    datStart = CDate(Me.txtTestDate)
    datend = CDate(Me.txtTestDate)
    ' strwhere = strwhere & " EIRELCTIRR_qry.CreatedOn between #" & datStart & "# And #" & datend & "# AND"
    strwhere = strwhere & " NSReschedules_qry.TestDate = #" & datStart & "# And "
    End If

    ElseIf Not IsNull(Me.txtTestDate2) Then
    datStart = CDate(Me.txtTestDate2)
    datend = CDate(Me.txtTestDate2) + 1
    ' strwhere = strwhere & " EIRELCTIRR_qry.CreatedOn between #" & datStart & "# And #" & datend & "# AND"
    strwhere = strwhere & " NSReschedules_qry.TestDate = #" & datStart & "# And "
    End If


    ' If Not IsNull(Me.txtSiteType) Then
    ' strWhere = strWhere & " SiteType Like '*" & Me.txtSiteType & "*' AND"
    ' End If


    ' Remove last " AND"
    If Not strwhere = "" Then
    strwhere = Left(strwhere, Len(strwhere) - 4)
    End If

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: VB module question (access 2003)

    Is SiteType a field in the table or tables on which the report is based?
    What is the field type of SiteType? Text, number or something else?

    Did you get an error message and if so, what did it say?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •