Okay here's my problem. I created a form (frmPOEntry) that has unbound controls that are bound to controls which has data bound to a temp table (did that make sense). The table that those controls are bound to has a subdatasheet (tblTodaysOrder) that is link using today's date. Now, when I enter a PO Number on the form, and I click the "Create PO" button (command button), a message box will pop up with vbYES and vbNo buttons. If vbYes is chosen, then a PO is created on the table (tblPONumber) and that PO is created with today's date, which then gets attached to the subdatasheet. Now all the records on the subdatasheet has that PO. I have a query that combines both the tblPONumber and its subdatasheet. When the PO Entry form is closed, the query runs and appends data to a seperate table (tblOrderHistory). Now, what I want to do is when the user clicks the "Create PO" button on the form (POEntry), I want to insert a code in there that searches the table 'tblOrderHistory' and if the PO number is already in tblOrderHistory then prompt a msgBox saying "Duplicate PO, please change PO number".
Here are the frmPOEntry objects:
Here's the code I have in the form
Private Sub cmdButton011_Click()
On Error GoTo Err_cmdButton011_Click
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Are you sure you want to create this PO?"
Style = vbYesNo + vbQuestion + vbDefaultButton2
Title = "Create PO?"
Help = "PO.Help"
Ctxt = 1000
If IsNull(Me![PONumber]) Then
MsgBox "Please Enter PO Number."
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.GoToRecord , , acNewRec
MsgBox ("You have created a new PO")