Hi Alvin,
I have renamed Dealer Type to "DealerType"
I thought your Dealer type control was a combo box(?). Rename it to
"cboDealerType" if you want to follow standard naming conventions.
Now I get error 2465 in form activate. It says it can't find the field '|'
Referred to in your expression.
Notice that your Form_Activate procedure includes the following line of code:
DoCmd.GoToControl "OrderID"
However, you have since renamed this control (I think) to txtOrderNo.
As MacDermott said in your follow-on post, titled "Re: error 2465 in
Form_Activate event Procedure", perhaps you could tell us what this code is
supposed to achieve?
Tom
____________________________________________
:
I have renamed Dealer Type to "DealerType"
Now I get error 2465 in form activate. It says it can't find the field '|'
Referred to in your expression. The title is Error in Form_Activate Event
Procedure.
I followed your instructions but no luck yet.
Here is my Form activate code:
Private Sub Form_Activate()
On Error GoTo Err_Form_Activate
Me.Requery
If IsLoaded("Orders by Customer") Then
If Forms![Orders by Customer]![Orders by Customer
Subform].Form.RecordsetClone.RecordCount > 0 Then
DoCmd.GoToControl "OrderID"
DoCmd.FindRecord Forms![Orders by Customer]![Orders by Customer
Subform].Form![OrderID]
End If
End If
Exit_Form_Activate:
Exit Sub
Err_Form_Activate:
MsgBox "Error " & Err.Number & ": " & Err.Description, , _
"Error in Form_Activate event procedure..."
Resume Exit_Form_Activate
End Sub
Thank you so much for your help!!
Alvin
____________________________________________
:
Hi Alvin,
Now when I open the order form it says;
"Microsoft can't move the focus to Controle OrderID"
I'm not sure how to fix this or if it really needs to be fixed.
I'd certainly want to fix it. You, or your users, should not be satisfied
having to view such an error message every time you open the form. Check your
VBA code for any references to OrderID, by using the find feature (Edit >
Find...). If you still cannot find it, then try using Tools > Analyze >
Documenter. Pick just the form in question. Click on the Option... button
and place checks in the top three boxes. Select the option button that reads
"Names and Properties". Click on OK two times to run the report. Without
closing the report, choose File > Export. Export the report as a rich text
document (*.RTF). You can then open this file in Word and search for OrderID.
I know that we have now added some more focus for "txtInvoiceNo" &
"cboDealer Type" and they may be conflicting.
I don't think you should have any conflicts here. However, did you rename
Combo69 to "cboDealer Type" or "cboDealerType"? I recommended no spaces in
the names of controls earlier.
Tom
____________________________________________
:
Thank you Tom
It is very close and I did rename the fields just like you suggested.
Now when I open the order form it says;
"Microsoft can't move the focus to Controle OrderID"
I'm not sure how to fix this or if it really needs to be fixed. I know that
we have now added some more focus for "txtInvoiceNo" & "cboDealer Type" and
they may be conflicting.
Thank you so much for the help!
Alvin
____________________________________________
:
Hi Alvin,
I recommend using the Form_BeforeUpdate event procedure, rather than the
Form_Current event procedure. Form_BeforeUpdate will only fire when a change
has been made to the data (ie. the form is dirty). Form_Current fires every
time you change records, whether you've made any changes to the data or not.
I also recommend renaming the Invoice# field to something like InvoiceNo.
You should avoid the use of special characters (#, spaces, etc.) in the names
of fields, objects (tables, queries, forms, reports, etc.) or the names of
controls on forms and reports. See the following KB article:
Special characters that you must avoid when you work with Access databases
http://support.microsoft.com/?id=826763
Now is a good time to rename Combo69 as well. Give it a name that makes
sense, such as cboDealerType. Name the textbox that displays the InvoiceNo
something like txtInvoiceNo. With those changes in place, you can then use
the following code:
Option Compare Database
Option Explicit
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo ProcError
If IsNull(txtInvoiceNo) Then
MsgBox "Please Enter an Invoice Number.", _
vbCritical, "Missing Required Value..."
txtInvoiceNo.SetFocus
Cancel = True
Exit Sub
End If
If IsNull(cboDealerType) Then
MsgBox "Please Select a Dealer Type.", _
vbCritical, "Missing Required Value..."
cboDealerType.SetFocus
Cancel = True
Exit Sub
End If
ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, , _
"Error in Form_BeforeUpdate event procedure..."
Resume ExitProc
End Sub
Tom
____________________________________________
:
In my order form I have two fields that I want to make sure they contain a
value.
one is a textbox which holds the invoice number and the other is a combo.
how can I have a personal MsgBox for each of these if there is no value in
them.
I'm not sure what to do.
Here is what I have.
Private Sub Form_Current()
If IsNull(Me![Invoice#]) Then
DoCmd.GoToControl "Invoice#"
MsgBox "You Must Enter A Unique Invoice# To This Order!"
End If
IsNull (Me![Combo69])
DoCmd.GoToControl "Combo69"
MsgBox "You Must Select A Dealer Type in Price Levels For This
Order", vbOK + vbExclamation
End If
End Sub
Thank you in advance for any help on this subject