UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
2 Pages V < 1 2  (Go to first unread post)
   Reply to this topicStart new topic
> User Entry Wildcard In A Query?, Access 2013    
 
   
RJD
post Aug 21 2019, 05:57 PM
Post#21


UtterAccess VIP
Posts: 10,080
Joined: 25-October 10
From: Gulf South USA


Hi: Try this approach ...

CODE
Public Sub RequeryForm(Frm As String, TxTBox As String)
   Forms(Frm).RecordSource = Forms(Frm).RecordSource
   Forms(Frm).Requery
   Forms(Frm).Controls(TxTBox).SetFocus
End Sub

And call it like this ...

CODE
Private Sub SearchModel_AfterUpdate()
  Call RequeryForm("frmParts", "Model")
End Sub

... changing the form name and control as required, of course ...

HTH
Joe

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 
RJD
post Aug 21 2019, 07:15 PM
Post#22


UtterAccess VIP
Posts: 10,080
Joined: 25-October 10
From: Gulf South USA


Hi: Just another thought. You should be able to get the form name from the form you are on to call the AfterUpdate event procedure ...

CODE
Private Sub SearchModel_AfterUpdate()
  Dim FormName As String
  FormName = Me.Name
  Call RequeryForm(FormName, "Model")
End Sub

... then you don't have to enter that in the Call procedure, just the control you want to have focus...

HTH
Joe

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 
ServiceMSA
post Aug 22 2019, 07:31 AM
Post#23



Posts: 19
Joined: 11-July 19



That works great, thank you.
All I changed was the "TxTBox" to "Ctl" since its actually a control name it should work with other controls like combo boxes and such correct?
Go to the top of the page
 
RJD
post Aug 22 2019, 09:48 AM
Post#24


UtterAccess VIP
Posts: 10,080
Joined: 25-October 10
From: Gulf South USA


Hi: You are very welcome.

But I'm not sure how to interpret your last statement. "TxtBox" is just a variable name, and the contents should be a string. I am not sure you mean that you renamed the variable name "TextBox" to "Ctl" or if you mean you made TextBox as a control instead of a string. The command line ... Forms(Frm).Controls(TxTBox).SetFocus ... identifies a control name found in the variable string named TextBox. The control name is just a string. You could just as easily call the variable "MyControl" or "SelectedControl" or even "X" or pretty much anything (no reserved words). It is just a name for containing the control name string, of any type control, you want to have the SetFocus apply to.

HTH
Joe

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 
ServiceMSA
post Aug 22 2019, 01:21 PM
Post#25



Posts: 19
Joined: 11-July 19



Yes I agree, its still a string and I renamed the variable to "Ctl". I did this because in the code the string "TxTBox" is actually a reference to a control name and therefore the code should work with other control types not just text boxes. So "Ctl" for control just makes more sense to me since I will use this with combo boxes and such. Originally when I first made a separate routine I couldn't figure out why my code wasn't working because I had tried TxTBox a control and a textbox, and neither worked. So I thought the Controls portion of Forms().Controls() must be something else which was my original question.

This is what it ended up as:
CODE
Public Sub Test(Frm As String, Ctl As String)
Forms(Frm).RecordSource = Forms(Frm).RecordSource
Forms(Frm).Requery
Forms(Frm).Controls(Ctl).SetFocus
End Sub
Go to the top of the page
 
RJD
post Aug 22 2019, 02:40 PM
Post#26


UtterAccess VIP
Posts: 10,080
Joined: 25-October 10
From: Gulf South USA


Okay, I think I understand. Looks like you are good-to-go with this now. Continued success with your project.

Regards,
Joe

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 
2 Pages V < 1 2


Custom Search


RSSSearch   Top   Lo-Fi    14th October 2019 - 04:22 PM