My project for tomorrow
thanks
Ian
My project for tomorrow
thanks
Ian
That was my feeling as well. Yours has the advantage of not hitting the data twice. It has the disadvantage of having to remember to trap the 2501 error. Do you also have to reopen frm_BaptismYearSearch? It looks like it would be left closed and the user left in limbo, or at least with no results and having to reopen the search form to search again.
It also provides for reporting any other error, although I doubt there would be any. I wanted to intrigue the OP with error handlingYours has the advantage of not hitting the data twice. It has the disadvantage of having to remember to trap the 2501 error. Do you also have to reopen frm_BaptismYearSearch? It looks like it would be left closed and the user left in limbo, or at least with no results and having to reopen the search form to search again.
I would not close the form in the button click event either; rather in the form open event if there were > 0 records, but only if I knew I would not want to run another search after the last one. Why not let the user close the form with a button when they're good and done?
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
THanks both,
I'll look tomorrow - have to move onto my wifes project - family history research in the US
Ian
Late in posting, but I had the construct that Paul suggested.
Code:'------------------------------------------------------------ ' btn_Search_Click ' '------------------------------------------------------------ Private Sub btn_Search_Click() TempVars.Add "varYear", Me.txtYearOfBaptism.Value If DCount("*", "tbl_Baptism", "YearOfBaptism= '" & Me.txtYearOfBaptism & "'") > 0 Then DoCmd.Close acForm, "frm_BaptismYearSearch" DoCmd.OpenForm "frm_BaptismYearSearchResults", acNormal, "", "", , acNormal Else DoCmd.OpenForm "frm_Noresults" End If End Sub
Hi
Many thanks for all the suggestions, spent the day implementing them and I have now grasped some concepts.
I ended up using
Because I did like it's simplicity ( probably not a good choice of words) in that I could follow the logic.Code:------------------------------------------------------------ ' btn_Search_Click ' '------------------------------------------------------------ Private Sub btn_Search_Click() TempVars.Add "varYear", Me.txtYearOfBaptism.Value If DCount("*", "tbl_Baptism", "YearOfBaptism= '" & Me.txtYearOfBaptism & "'") > 0 Then DoCmd.Close acForm, "frm_BaptismYearSearch" DoCmd.OpenForm "frm_BaptismYearSearchResults", acNormal, "", "", , acNormal Else DoCmd.OpenForm "frm_Noresults" End If End Sub
I now want to apply the same principle top some other forms , which I have done and they all work
but ( ok there is always a but;-
the results form that opens is based on a query containing a wild card
When I implement the Dcount code it looses it's wild card component in the results, so a look at the code showedCode:Like [TempVars]![varBrideForenames] & "*"
"*" in the query and "'" in the Dcount code.
Ah Ha I said and changed the ' to a *
Sucess I thought!! I thought wrong ;-(
Did a search for "'" in google but no results to explain
thanks
Ian