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!

warn before text box edit

Status
Not open for further replies.

gneff

Technical User
Aug 24, 2002
15
US
I am using access as a custom estimating program and all projects are named. this is done by selecting the "new" button DoCmd.GoToRecord , , acNewRec
Forms![JOBMASTER]![JOBNAME] = "** New Job **"
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Forms![JOBMASTER]![TAKEOFF]![TAKEOFFID] = DMax("[TAKEOFFID]", "TAKEOFF", "[JOBID]") + 1
Forms![JOBMASTER]![TAKEOFF]![qryJOBCASE subform]![JOBCASENO] = DMax("[JOBCASENO]", "JOBCASE", "[JOBID] = " & JOBID) + 1
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Forms![JOBMASTER]![JOBNAME].SetFocus

this is the identifier for the project(they replace the **New Job** with a project name) but sometimes my estimators mistakenly type in a new name in and it screws everything up. I want to find some code to warn them they are changing the name. Can anyone help?

 
A little more info...
Are your projects always named before the estimators enter their data?
If so, are you just trying to limit what they can enter into the textbox?

Eric
 
If all you want to do is warn them to be careful use the 'on got focus' event to trigger a message box with the relevant warning.

If you want to get them to check the entry the have made use the 'on update' event, or one of the other events that run after some activity to trigger a message box. Use the message box to get a response and either save or undo the entry depending on the response.

Of course, you could do both :)

If you need help using a message box to get a response reply and I'll post a couple of lines of code as an example.

Ian
 
Response to luceze is as follows: Project when created is **new job**, then the estimator names (enters the project name overwriting **new job**) the project which of course has a autonumber associated with it. What happens is during input they mistakenly type in the field which creates lots of problems. The name should never change once it is entered. I just want to warn them they made a mistake.Hope this is clear
 
Try something like this in the on dirty event of your text box:

If Not IsNull(Me.Text21) Then
msgbox "You have already entered a job name."
DoCmd.CancelEvent
Me.Text21.Undo
End If
 
works great but need to be able to input data during inital start so does this work?
If Not Is**New Job**(Me.JOBNAME) Then
MsgBox "You have already entered a job name."
DoCmd.CancelEvent
Me.JOBNAME.Undo
End If

 
Try this

If me.jobname <> &quot;**New Job**&quot; Then
msgbox &quot;You have already entered a job name.&quot;
DoCmd.CancelEvent
Me.jobname.Undo
End If

HTH,
Eric
 
seems like it should but doesn't work will not allow edit of ** New Job **
 
Try changing
If me.jobname <> &quot;**New Job**&quot; Then
to
If me.jobname <> &quot;** New Job **&quot; Then

Eric
 
did that , I also tried an else command I think since I am doing it before change is the problem and since I never end up after the change with NEW Job I cannot accomplish it at that point but here is code that also doesn't work

If me.jobname = &quot;** New Job **&quot; Then
DoCmd. (whatever)
Else
If me.jobname <> &quot;** New Job **&quot; Then
msgbox &quot;You have already entered a job name.&quot;
DoCmd.CancelEvent
Me.jobname.Undo
End If
End If
 
It works fine on my end. If you want you can send me a desensitized copy of you DB and I will take a look at it.
eisom@esc11.net

Eric
 
OK, read the thread to date, this may help, or just confuse and hinder so feel free to ignore me.

Add a new field to the datatable, a yes/no for preference.

Set the on update event for the 'new job' control to change the yes/no field from its default no to yes. This is easily done by putting the yes/no field on the form and setting its visible property to false. Then in the on update event: -

me.yes/no = true

will make the change.

Set the on got focus event to check the yes/no field's value. If the value indicates the job name field has been completed run a message box to inform the user and then set the focus to the nearest relevant field. A simple: -

If me.yes/no = true then
msgbox &quot;Job name already set&quot;
me.anyothercontrol.setfocus
else
'do nothing
end if

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top