Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

Visual basic form

I have table Employee in database with 5 fields (id, FirstName, LastName, Age, BirthDate, Salary)
I want to wright form in visual basic that has 2 textboxes ( FromDate, ToDate ) and button -("Go").
When I press on button I want to see table Employee filtered by BirthDate.
Can somebody explain with code example how I do it. Working example will be graded with 100 points more.
Thank you in advance.
0
LazyStudent
Asked:
LazyStudent
1 Solution
 
JRCSystemsCommented:
Private Sub cmdGo_Click()
Dim pdDateFrom as Date
Dim pdDateThru as Date
Dim psSQL      as String
Dim poRS       as RecordSet


    if IsDate(txtDateFrom.text) then
       pdDateFrom = CDate(txtDateFrom.text)
    else
       pdDateFrom = 0
    end if

    if IsDate(txtDateThru.text) then
       pdDateThru = CDate(txtDateThru.text)
    else
       pdDateThru = Now
    end if

    psSQL = "Select * from Employee where " _
            "BirthDate >= #" & pdDateFrom & "# AND " & _
            "BirthDate <= #" & pdDateThru & "#"

   
    set poRS = moDB.OpenRecordset(psSQL, dbOpenDynaset)
    Do While not poRS.EOF
'      print/display data
       poRS.MoveNext
    Loop
    poRS.Close
    set poRS = Nothing

End Sub

0
 
LazyStudentAuthor Commented:
Can you provide 'print/display data ? ( better - list(Report) control?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now