Private Sub CREPORT_Click()
On Error GoTo ErrorTrap
TSQL = ""
TSQL = "SELECT * FROM LEAVE_TABLE WHERE FIRM='" & COMFIRMNAME.Text & "' AND S_DATE BETWEEN #" & DTP1.Value & "# and #" & DTP2.Value & "#"
Set RTMP = Get_Special_Record_Set(TSQL)
If RTMP.RecordCount = 0 Then
MsgBox "Record Not Found", vbInformation
Exit Sub
End If
With FIRM_STATUS
Set .DataSource = Nothing
Set .DataSource = RTMP.DataSource
End With
'firm status is datareport name
'don't forget to write all control in section 1 of your report
'coding by banna
With FIRM_STATUS.Sections("Section1").Controls
.Item("LD1").Caption = DTP1.Value
'label first name ld1
.Item("LD2").Caption = DTP2.Value
'label second name ld2
.Item("TXTFIRM").DataMember = ""
.Item("TXTFIRM").DataField = RTMP.Fields("FIRM").Name
'textbox first name txtfirm
'firm is field firm in the table
.Item("TXTLOCATION").DataMember = ""
.Item("TXTLOCATION").DataField = RTMP.Fields("LOCATION").Name
'txtbox second name txtlocation
'location is field location in the table
.Item("LABNOEMP").Caption = EMP
'label third name labnoemp
.Item("LSALARY").Caption = Val(SALARY)
'label lsalary name lsalary
End With
FIRM_STATUS.Refresh
'firm_status is datareport name
FIRM_STATUS.Show
ErrorTrap:
If Err.Number <> 0 Then
MsgBox "Error (" & Err.Number & "): " & Err.Description, vbCritical, "Error"
End If
End Sub