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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return to A Cleared Field After An Update [Event Procedure]

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Need some help on this one.
I enter “xxx” in a form, then the after update event is an if then else if then else statement. One of the three results opens a form that when it is closed I would like to return to the same field I entered “xxx”, but I need to have it cleared (waiting for the data to be re-entered).
 
In you If Then statement, open your form and also put a line that says Me.Undo which should remove the text that was input.

In your pop up form, in the OnClose event, use something like MainFormName!Nameof FieldToReturnTo.SetFocus

Hope this helps
 
open the form in acDialog mode, set the TextBox value to null, shift focus to another control then bring it back.

Private Sub txt1_AfterUpdate()
DoCmd.OpenForm "frmDialog", , , , , acDialog
txt1 = vbNullString
txt2.SetFocus
txt1.SetFocus
End Sub


PaulF
 
OK Some Guy,
I got the first half of the problem solved, but after I close the PopUp it doesn't like the SetFocus Command. It maybe a format issue. Here's what I wrote:

Private Sub Form_Close()
FormName!TableName!FieldName.SetFocus
End Sub

Any suggestions?
 
Try this

Private Sub Form_Close() Forms![FormName]![FieldName].SetFocus
End Sub
 
That Resulted in:
Run-Time Error '438'
Object doesn't support this property or method


 
Hi,
You aren't setting focus to the table's field, so don't do this:

FormName!TableName!FieldName.SetFocus

You shoud be referencing a control that is on the form like:
Me.MyTextbox.SetFocus


Rob Marriott
rob@career-connections.net
 
Hi Rob,
I get the part about the textbox verses the table name thanks for that awakening. Now it doesn’t recognize the textbox. I tried “Me” and also the name of the form with no luck. I think it’s looking at the form I’m closing, not the one that’s open behind it.
Any Ideas !
 
Try: Forms!<Form Name>.<Control Name>.SetFocus

Rob Marriott
rob@career-connections.net
 
I’m BACK!!!
OK as a stated in the beginning: I want to return to the main form in the same field cleared of data. What I’ve achieved so far Is I can return to the same field with “xxx’ in the field or I can return back to a “All fields cleared form”. What I need is to return to the form with all data intact except the GetFocus field. I need this clear of data.
 
Are you simply trying to clear the text box? If so, just set its value to &quot;&quot; ie. MyText = &quot;&quot; or Me.ActiveControl = &quot;&quot;. Otherwise I'll need more info on what you are trying to do.

Rob Marriott
rob@career-connections.net
 
Maybe I'm using the wrong word. I want to return to the form and DELETE the data that was entered that initiate the afterUpdate event. I may be going at this in the wrong way, but what I’m trying to achieve is like this: Enter data in field “ID” of form “Add” then check for 3 scenarios, 1,2 or 3, if 3 open form “Fix”, complete form “Fix”, then on close return to form “Add” field “ID” with the data cleared, so when it’s reentered it will choose between scenario 1 and 2.
Am I making any sense?
 
Hi Rob,
I started to think about what I last said I wanted to accomplish then I realized there was a simpler way.
Let me start again from: if scenario 3 open form “Fix”, complete form “Fix”, then on close open form for scenario 2, complete that form then on close return to form “Add”. See I didn’t need the set focus command after all, but I did learn a lot trying to go about this the hard way.
Thanks for the help. All is fine. For the moment anyway!
 
Glad to hear that everthing worked out good for you.

Rob Marriott
rob@career-connections.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top