Hi All,
Just wondering if anyone can see anything wrong with my code... trying to get prior entered data to fill the form when press F7 or F8. If I press Escape it runs the Form_keypress, but F7 and F8 doesn't.
I do have the form keypreview set to True.
Thanks!
Private Sub Form_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case vbKeyEscape
Unload Me
Case vbKeyF7
' copy last entered invoice to form
With rsTempInvoice
.Open "SELECT * FROM tblTempInvoice ORDER BY InvoiceNumber", cnREVS, adOpenStatic, adLockReadOnly
If .RecordCount > 0 Then
.MoveLast
txtInvoiceNumber.Text = !InvoiceNumber + 1
txtLineItemNumber.Text = 1
txtDistrictID.Text = !DistrictID
txtInvoiceDate.Text = !InvoiceDate
txtEventDate.Text = !EventDate
txtGroupNum.Text = !GroupNum
txtAmount.Text = !Amount
txtPONumber.Text = !PONumber
txtDescription.Text = !Description
End If
.Close
End With
Case vbKeyF8 'copy last entered invoice except district, line, & invoice
With rsTempInvoice
.Open "SELECT * FROM tblTempInvoice ORDER BY InvoiceNumber", cnREVS, adOpenStatic, adLockReadOnly
If .RecordCount > 0 Then
.MoveLast
txtInvoiceNumber.Text = ""
txtLineItemNumber.Text = ""
txtDistrictID.Text = ""
txtInvoiceDate.Text = !InvoiceDate
txtEventDate.Text = !EventDate
txtGroupNum.Text = !GroupNum
txtAmount.Text = !Amount
txtPONumber.Text = !PONumber
End If
.Close
End With
End Select
End Sub
Just wondering if anyone can see anything wrong with my code... trying to get prior entered data to fill the form when press F7 or F8. If I press Escape it runs the Form_keypress, but F7 and F8 doesn't.
I do have the form keypreview set to True.
Thanks!
Private Sub Form_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case vbKeyEscape
Unload Me
Case vbKeyF7
' copy last entered invoice to form
With rsTempInvoice
.Open "SELECT * FROM tblTempInvoice ORDER BY InvoiceNumber", cnREVS, adOpenStatic, adLockReadOnly
If .RecordCount > 0 Then
.MoveLast
txtInvoiceNumber.Text = !InvoiceNumber + 1
txtLineItemNumber.Text = 1
txtDistrictID.Text = !DistrictID
txtInvoiceDate.Text = !InvoiceDate
txtEventDate.Text = !EventDate
txtGroupNum.Text = !GroupNum
txtAmount.Text = !Amount
txtPONumber.Text = !PONumber
txtDescription.Text = !Description
End If
.Close
End With
Case vbKeyF8 'copy last entered invoice except district, line, & invoice
With rsTempInvoice
.Open "SELECT * FROM tblTempInvoice ORDER BY InvoiceNumber", cnREVS, adOpenStatic, adLockReadOnly
If .RecordCount > 0 Then
.MoveLast
txtInvoiceNumber.Text = ""
txtLineItemNumber.Text = ""
txtDistrictID.Text = ""
txtInvoiceDate.Text = !InvoiceDate
txtEventDate.Text = !EventDate
txtGroupNum.Text = !GroupNum
txtAmount.Text = !Amount
txtPONumber.Text = !PONumber
End If
.Close
End With
End Select
End Sub