Results 1 to 3 of 3
  1. #1
    dongodu is offline Novice
    Windows XP Access 2003
    Join Date
    May 2011
    Posts
    11

    Any sugesstions

    Code:
    Private Sub cmdDinchu_Click()
    Set obj = New PrinterControl
    obj.ChngOrientationPortrait
    Call ConnectMe
    Set rs = New ADODB.Recordset
    
    rs.Open "select * from reser where res_date between '" & Text1.Text & "' and '" & Text2.Text & "' and pron Between '" & Text3.Text & "' and '" & Text4.Text & "'and pron between '" & Text5.Text & "' and '" & Text6.Text & "' and pblkno between '" & Text7.Text & "' and '" & Text8.Text & "'", con, 1, 3
    
    If rs.RecordCount = 0 Then
        MsgBox "No record found on query.", vbCritical, "Medrar"
       
    Else
        Set Reservartion_List.DataSource = rs
        Unload Me
        Reservartion_List.Show
    End If
    
    Set rs = Nothing
    End Sub


  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    What is your question? Does this code work - if not, why? Error message, no results, bad results?

    On first glance, may be error in SQL syntax. Is res_date field a data/time datatype? If so, use # as delimiter character instead of apostrophe. If the other fields are number type, no delimiter is used.

    Also, is Reservartion_List correct with the second r? This is a form? Why are you changing the DataSource? Why not just filter the form?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Code:
    where 
    res_date between '" & Text1.Text  & "' and '" & Text2.Text & "' 
    and pron Between '" &  Text3.Text & "' and '" & Text4.Text & "'
    and pron between '"  & Text5.Text & "' and '" & Text6.Text & "' 
    and pblkno  between '" & Text7.Text & "' and '" & Text8.Text & "'"
    First of all if res_date is a date field this query will not work
    You would need to have this:
    Code:
    res_date between #" & Text1.Text  & "# and #" & Text2.Text & "#
    Secondly, if either pron or pblkno is a number or date field then again your code will not work. let's assume pblkno is in fact a number you would want this:
    Code:
    and pblkno  between " & Text7.Text & " and " & Text8.Text

Please reply to this thread with any new information or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums