|
|
Hi Groupies
I use the following code on a command button to open a form to a newly created record based on data input into a form.
stDocName = "frmWorkOrder" stLinkCriteria = "[lngWOId]=" & Me![lngWOId]
DoCmd.RunCommand acCmdSaveRecord DoCmd.OpenForm stDocName, , , stLinkCriteria
My question is how do I open the form frmWorkOrder to the new record but remove the form filter so that I can move to other records?
I have tried using DoCmd.OpenForm stDocName, , acEntire, stLinkCriteria but that just gives me an error message.
-- Thanks for taking the time!
CJ --------------------------------------------------------- Know thyself, know thy limits....know thy newsgroups!
|
|
You can't. You would have to open the form to all records first, then use the FindFirst method to hunt down the record you just saved based on some criteria. Too much work. I would simply put a button on the form called Show All with Docmd.ShowAllRecords behind it. That way the form will open to your new record as instructed, but when you're done with it, just hit the new Show All button. There's also a toobar button that removes the filter.
Rip
"CJ" <private[ at ]newsgroups.com> wrote in message news:OTISEtqTJHA.1908[ at ]TK2MSFTNGP04.phx.gbl...
[Quoted Text] > Hi Groupies > > I use the following code on a command button to open a form > to a newly created record based on data input into a form. > > stDocName = "frmWorkOrder" > stLinkCriteria = "[lngWOId]=" & Me![lngWOId] > > DoCmd.RunCommand acCmdSaveRecord > DoCmd.OpenForm stDocName, , , stLinkCriteria > > My question is how do I open the form frmWorkOrder to the new record > but remove the form filter so that I can move to other records? > > I have tried using DoCmd.OpenForm stDocName, , acEntire, > stLinkCriteria > but that just gives me an error message. > > -- > Thanks for taking the time! > > CJ > --------------------------------------------------------- > Know thyself, know thy limits....know thy newsgroups!
|
|
"CJ" <private[ at ]newsgroups.com> wrote in message news:OTISEtqTJHA.1908[ at ]TK2MSFTNGP04.phx.gbl...
[Quoted Text] > Hi Groupies > > I use the following code on a command button to open a form > to a newly created record based on data input into a form. > > stDocName = "frmWorkOrder" > stLinkCriteria = "[lngWOId]=" & Me![lngWOId] > > DoCmd.RunCommand acCmdSaveRecord > DoCmd.OpenForm stDocName, , , stLinkCriteria > > My question is how do I open the form frmWorkOrder to the new record > but remove the form filter so that I can move to other records? > > I have tried using DoCmd.OpenForm stDocName, , acEntire, > stLinkCriteria > but that just gives me an error message.
So lngWOId identifies the record you just created and saved? You can open the form and position it to that record like this:
DoCmd.OpenForm strDocName Forms(strDocName).Recordset.FindFirst stLinkCriteria
-- Dirk Goldgar, MS Access MVP www.datagnostics.com
(please reply to the newsgroup)
|
|
Hi Dirk, thanks for popping in.
Your code worked perfectly, thanks very much!
-- Thanks for taking the time!
CJ --------------------------------------------------------- Know thyself, know thy limits....know thy newsgroups! "Dirk Goldgar" <dg[ at ]NOdataSPAMgnostics.com.invalid> wrote in message news:OyZD%23PrTJHA.584[ at ]TK2MSFTNGP06.phx.gbl...
[Quoted Text] > "CJ" <private[ at ]newsgroups.com> wrote in message > news:OTISEtqTJHA.1908[ at ]TK2MSFTNGP04.phx.gbl... >> Hi Groupies >> >> I use the following code on a command button to open a form >> to a newly created record based on data input into a form. >> >> stDocName = "frmWorkOrder" >> stLinkCriteria = "[lngWOId]=" & Me![lngWOId] >> >> DoCmd.RunCommand acCmdSaveRecord >> DoCmd.OpenForm stDocName, , , stLinkCriteria >> >> My question is how do I open the form frmWorkOrder to the new record >> but remove the form filter so that I can move to other records? >> >> I have tried using DoCmd.OpenForm stDocName, , acEntire, >> stLinkCriteria >> but that just gives me an error message. > > > So lngWOId identifies the record you just created and saved? You can open > the form and position it to that record like this: > > DoCmd.OpenForm strDocName > Forms(strDocName).Recordset.FindFirst stLinkCriteria > > > -- > Dirk Goldgar, MS Access MVP > www.datagnostics.com > > (please reply to the newsgroup) >
|
|
Hi Ripper
FYI Dirk had a solution that was super simple.
DoCmd.OpenForm strDocName Forms(strDocName).Recordset.FindFirst stLinkCriteria
-- Thanks for taking the time!
CJ --------------------------------------------------------- Know thyself, know thy limits....know thy newsgroups! "RipperT [ at ]nOsPaM.nEt>" <<RiPpErT> wrote in message news:Ohe%231JrTJHA.5080[ at ]TK2MSFTNGP03.phx.gbl...
[Quoted Text] > You can't. You would have to open the form to all records first, then use > the FindFirst method to hunt down the record you just saved based on some > criteria. Too much work. I would simply put a button on the form called > Show All with Docmd.ShowAllRecords behind it. That way the form will open > to your new record as instructed, but when you're done with it, just hit > the new Show All button. There's also a toobar button that removes the > filter. > > Rip > > > "CJ" <private[ at ]newsgroups.com> wrote in message > news:OTISEtqTJHA.1908[ at ]TK2MSFTNGP04.phx.gbl... >> Hi Groupies >> >> I use the following code on a command button to open a form >> to a newly created record based on data input into a form. >> >> stDocName = "frmWorkOrder" >> stLinkCriteria = "[lngWOId]=" & Me![lngWOId] >> >> DoCmd.RunCommand acCmdSaveRecord >> DoCmd.OpenForm stDocName, , , stLinkCriteria >> >> My question is how do I open the form frmWorkOrder to the new record >> but remove the form filter so that I can move to other records? >> >> I have tried using DoCmd.OpenForm stDocName, , acEntire, >> stLinkCriteria >> but that just gives me an error message. >> >> -- >> Thanks for taking the time! >> >> CJ >> --------------------------------------------------------- >> Know thyself, know thy limits....know thy newsgroups! > >
|
|
|