Can someone please suggest some things that will improve my database? In the payment query the "total paid" field is not updating as soon as you click "update payment" and the booking session form "unbook" doesn't not do the "unbooking" process instantly either, you have to go to another record or close the form and click "unbook" again for it to update. Also, does anyone know how I would do the mail merge properly, I just want selected names from the customer table to be appended to labels (for printing), I have some code on mail merge in the "frmMailMerge" form, but I keep getting the same error :S
Cheers anyone that can help
Anyway here is the code for "unbook"
and here is the code for payment update
IF anyone wants a copy of the database to look at more closely, let me know cos you can't submit more than 100k on this silly forum :S and I only got dialup, so I got a prob uploading to my ftp server :S
THANKS HEAPS
Cheers anyone that can help
Anyway here is the code for "unbook"
Code:
Private Sub btnUnBook_Click()
'This does the unbook procedure
'On Error GoTo Err_btnUnBook_Click
Me.Refresh
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim rst2 As DAO.Recordset
Dim SQL As String
Dim startTimeValue As String
Dim endTimeValue As String
Set dbs = CurrentDb
If day = "Saturday" Then
startTimeValue = cboSatStartTime
endTimeValue = cboSatStartTime
Else
startTimeValue = cboWkStartTime
endTimeValue = cboWkEndTime
End If
SQL = "SELECT * " & _
"FROM tblSessionBooking " & _
"WHERE ((day = '" & day & "') AND (startTime = #" & startTimeValue & "#) AND (endTime = #" & endTimeValue & "#)) "
SQL2 = "SELECT * " & _
"FROM tblBooking " & _
"WHERE ((membershipNo = " & cboMembershipNo & ") AND (bookingNo = " & cboBookingNo & ")) "
Set rst = dbs.OpenRecordset(SQL)
Set rst2 = dbs.OpenRecordset(SQL2)
If (rst2!bookedIn = False) Then
MsgBox ("Person is already removed from this booking")
Else
If (rst!sessionCount > 0) Then
rst.Edit
rst!sessionCount = rst!sessionCount - 1
rst2.Edit
rst2!bookedIn = 0
'DoCmd.SetWarnings (False)
MsgBox ("Session has been unbooked for " & firstName & " " & lastName & ".")
rst.update
rst2.update
Else
MsgBox ("Session is Empty")
End If
End If
Set rst = Nothing
Set rst2 = Nothing
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_btnUnBook_Click:
Exit Sub
Err_btnUnBook_Click:
MsgBox ("Problem has occured, please click again")
Resume Exit_btnUnBook_Click
End Sub
and here is the code for payment update
Code:
'This procedure checks to see if the amount in 'Pay Amount' is valid,
' and that all feilds are appropriate
Private Sub txtAmtPaid_AfterUpdate()
Form.Repaint
If (txtTotalPaid = txtPrice) Then
MsgBox ("Amount for this membnership has already been paid in full!")
Else
If ((txtAmtPaid > price) Or (txtTotalPaid > txtPrice)) Then
MsgBox ("Please enter a valid amount!")
txtAmtPaid = 0
Else
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim SQL As String
Set dbs = CurrentDb
SQL = "SELECT Sum(amtPaid) AS totalPaid " & _
"FROM tblPayment " & _
"HAVING membershipNo = " & cboMembershipNo & ";"
Set rst = dbs.OpenRecordset(SQL)
txtTotalPaid = rst!totalPaid
txtPayDate = DateValue(Now())
Set rst = Nothing
End If
End If
End Sub
Private Sub btnPayUp_Click()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim SQL As String
Set dbs = CurrentDb
SQL = "SELECT Sum(amtPaid) AS totalPaid " & _
"FROM tblPayment " & _
"HAVING membershipNo = " & cboMembershipNo & ";"
Set rst = dbs.OpenRecordset(SQL)
make_changes()
txtTotalPaid = rst!totalPaid
Set rst = Nothing
End Sub
THANKS HEAPS