Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stuck

Status
Not open for further replies.

ODBCERRORKING

Technical User
Mar 29, 2001
27
US
i have an access 2000 .mdb with a user form being used as the main user screen i have a field called status_codes on the userform that field is a dropdown box they click the correct status and currenly move on. the problem is the users r not coding this field and we dont know how its being dispositioned. i would like if the user dont code this field that they can not go to the next record or somthing that will not let them go furter until populated coerctly.
 
DID NOT DO THIS YET BUT ALSO CAN I DISPLAY A MESSAGE TO THE USER LIKE THIS?

STATUS NEEDS TO BE UPDATED!
 
assuming your drop-down box is called cboStatusCodes

[ol]
[li]open your properties toolbar[/li]
[li]under the whole form's properties[/li]
[li]click the events tab of the properties[/li]
[li]add an [event procedure] to the After Insert event[/li]
[li]add the following code:
Code:
If isNull(Me.cboStatusCodes) Then
    MsgBox "STATUS NEEDS TO BE UPDATED!"
    Me.cboStatusCodes.SetFocus
End If
[/li][/ol]
give that a try... in place of the "isNull(Me...)" you can put whatever test is relevant for your application. i did a proof of concept .mdb on that.. if you would like a sample email me. Earnie Eng
If you are born once, you will die twice.
If you are born twice, you will die once
 
After Insert event
I GOT LOST I DONT KNOW WHERE TO PUT THE CODE? WILL THIS WORK BECAUSE FOR INSTANCE THEY FILTER FOR A PARTICULAR RECORD THEY UPDATE CONSUMER INFO EXAMPLE NAME AND PHONE NUMBER THEN FORGET TO DISPOSITION THE CALL IM JUST CONCERNED NOT A PROGRAMER BUT AFTER THEY INSERT WHAT? IS MY ????? IF THEY NEVER CLICKED THE DROPDOWN WHAT DID THEY INSERT OR IS IT GONNA BE ON THE NULL RECORDS.
 
[ol]
[li]in the properties window, after you find the "After Insert" event, you have the option of changing its prameters.[/li]
[li]click on that event's field in the property box, and expand the pull-down menu.[/li]
[li]select "event procedure"[/li]
[li]a little button to the right of the field should be there.. click it[/li]
[/ol]
A code window should pop up where you can insert the code.
If I understand you clearly from your last post, you aren't sure about the correct syntax for the code?

if the StatusCodes drop-down menu already has a value and you want to check for if it is updated or not, here is one way I can think of:

it will take one global variable, and code in a few bits of code in various events. I'll past what I've come up with, but I haven't fully tested it yet...

Code:
Option Compare Database
'--- Step 1: define a variable for testing
'            if the StatusCode was updated
Dim blnStatusCodeUpdated As Boolean

Private Sub Form_BeforeInsert(Cancel As Integer)
'--- Step 2: reset the variable before it is used.
    blnStatusCodeUpdated = False
End Sub

Private Sub cboLTC_AfterUpdate()
'--- Step 3: set the variable to TRUE
'            if the user updated the status code
    blnStatusCodeUpdated = True
End Sub

Private Sub cboLTC_Exit(Cancel As Integer)
'--- Step 4a: if the user tabs to this field,
'             but doesn't update it... warn him.
    If Not blnStatusCodeUpdated Then
        MsgBox "exit... PLEASE UPDATE STATUS CODE"
        Me.cboLTC.SetFocus
    End If
End Sub

Private Sub Form_AfterInsert()
'--- Step 4b: check and see if the status code was updated
'             if the user continues to next record
    If Not blnStatusCodeUpdated Then
        MsgBox "afterinsert... PLEASE UPDATE STATUS CODE"
        Me.cboLTC.SetFocus
    End If
End Sub

all the sub procedure names (i.e. "Private Sub cboLTC_Exit(Cancel As Integer)") are generated automatically by access when you add an event procedure to the form object, or one of its controls via the properties panel. So you don't have to copy all of my code, verbatim... just the innards to each of the procedure.

you can change the vairable names accordingly. Earnie Eng
If you are born once, you will die twice.
If you are born twice, you will die once
 
How 'bout checking the field in the OnBeforeUpdate event of the form. If nothing has been entered, then Cancel the update.

Private Sub Form_BeforeUpdate(Cancel As Integer)

If (Me.Dirty) and (FieldNotChanged) then
msgbox "You must enter something"
Cancel = True
End if

End Sub

If you want to clear the variable everytime they goto a new record, then in the OnCurrent event of the Form do something like this:

Private Sub Form_Current()

TextField = Null

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top