- Local time
- Today, 17:40
- Joined
- Feb 28, 2001
- Messages
- 30,618
Dick, the SQL I'm talking about is in the form's .RecordSource, not in your form-opening code. I might have been a little vague in specifying that, for which I'm sorry.
When you say "alphabeticize", do you mean "sort"
Is the form based on a query? If so have a look at the query properties, and see if a filter or sort uses the field [id]. Maybe that field is not included in the query, and that is causing a problem. That sort of thing.
I thought you meant add capital letters to the first letter of words in all the church nam
My Bad, yes sort. As of right now I can't find a query. The form record source is main table. (Probable my bad again) but I coded this 25 years ago. I wanted to hunt for SQL in data source but haven’t had time. Today my lawn mower died, took 3 hours to get bolt out of my truck hitch to get my trailer on, and gets a call they just took my wife to ER. Got a call from VA and they want to stick it up my butt. <G> (colonoscopy) Just got back from ER nothing serious as of now. Did a quick search of table, no SQL or at least I don’t know where to look.When you say "alphabeticize", do you mean "sort"
Is the form based on a query? If so have a look at the query properties, and see if a filter or sort uses the field [id]. Maybe that field is not included in the query, and that is causing a problem. That sort of thing.
I thought you meant add capital letters to the first letter of words in all the church names.
CHID Church Id autoNumberOK, now we are getting crazy. If your .RecordSource is a table, then no function can be involved there unless there is a computed field in the table.
The question is then going to be, "What happens in the form's _Open, _Load, and _Current events?" Because that error message says that SOMETHING is diddling with something that shouldn't be diddled with. I'm going to make a wild-eyed guess here. Does that table have a field called ID and is that field an autonumber? And if so, is there code in one of the form events that tries to assign a value to the ID field?
It took me a while to figure out this thing, but I opened the frmChurchesAllDick form and then deleted and replaced the txtChurch textbox control with a new one. After I did that, then the sorts worked in both datasheet view and regular form view. It appears the textbox control itself was the problem. So:No rude comments. <grin>I made this over 25 years ago.
Wow! amazing. What prompted you to try and replace "txtChurch" text box. I know the whole DB is a mess, but I have tried a coup of times to create a new completely new DB and import all the data but was never successful. I even offered someone payment to make one for me and they just laughed. I can't get rid of it as it's something I have to use constantly. It has over 13000 records. Thanks, as soon as I close here, I will try it on mine copy.It took me a while to figure out this thing, but I opened the frmChurchesAllDick form and then deleted and replaced the txtChurch textbox control with a new one. After I did that, then the sorts worked in both datasheet view and regular form view. It appears the textbox control itself was the problem. So:
There are lots and lots of naming convention issues as well as other problems in this file and you don't even have the CHID field set as a Primary key in the tblCHURCHES table, but I make no further comments. If you replace the txtChurch textbox with a brand new one, I got the sorts to work.
- Open frmChurchesAllDick in design mode
- Delete the txtChurch textbox control
- Add a new textbox control and bind it to the txtChurch field as you did previously
You are so right. Back then I add stuff quickly so I could get to the task of building my ministry, and not spend time studying how to do it correctly, so ended up with all kind of junk that I didn't need. Actually, I could have managed without fixing the sort problem as it sorted anyways but gave me that error message and it's been bugging me for years. Thanks everybody AWF great place, I love it. BTW: I read many years ago how some of the UK guys got together and thought that was a good idea and over the years tried it in the US. Only success I have had was with Doc and a guy in Jacksonville, FL and he has since moved. So, try, and try again. I will be in Lewisburg, WV for two weeks in August. Any AWF people want to get together for coffee, give me a shout.@Dick7Access
On your form Dicks Churches, there is a non visible text box with the control source =IIf(IsNull([ID]),"(New)","Open")
I deleted the control source, and that stopped the error. It must be something you used a long while ago.
Jenny doesn't seem to have that text box!
ThanksWhat prompted me to try that is if you sorted the CHID field, the sorting worked, so the problem was not the form itself, so it had to be one of the other fields and the only other field that contained data was the txtCHURCH field. Actually, I have seen this problem before in other databases. It is rare, but happens. This error can be caused in hundreds of ways though. Gemmas suggestion is also valid. Get rid of that field if it doesn't do anything. The syntax is wrong anyway.
You don't need to use datasheet view to sort anyway. You can just add 2 commandbuttons to the form. One for Sort ascending and one for sort descending. On the On Click event put the following VBA code for Ascending:Thanks
DoCmd.GoToControl "txtCHURCH"
DoCmd.RunCommand acCmdSortAscending
DoCmd.GoToControl "txtCHURCH"
DoCmd.RunCommand acCmdSortDescending
I don't think that will quite do it. Many times, I am looking for a church and all I have is the pastors last or first name or some other field or first name and city, or sometimes just a zip code.You don't need to use datasheet view to sort anyway. You can just add 2 commandbuttons to the form. One for Sort ascending and one for sort descending. On the On Click event put the following VBA code for Ascending:
and for Descending:Code:DoCmd.GoToControl "txtCHURCH" DoCmd.RunCommand acCmdSortAscending
Then just click the buttons to sort.Code:DoCmd.GoToControl "txtCHURCH" DoCmd.RunCommand acCmdSortDescending
What is wrong with a simple Find then?I don't think that will quite do it. Many times, I am looking for a church and all I have is the pastors last or first name or some other field or first name and city, or sometimes just a zip code.
Then you should not be sorting anyway, you should be performing a search in all fields on the form for what you are looking for and finding matches. You use the DoCmd.FindRecord command to do that.I don't think that will quite do it. Many times, I am looking for a church and all I have is the pastors last or first name or some other field or first name and city, or sometimes just a zip code.
Dim Criteria As String
Criteria = Me.SearchCriteria
DoCmd.FindRecord Criteria, acAnywhere, , acSearchAll, , acAll
Dim Criteria As String
Criteria = Me.SearchCriteria
DoCmd.FindNext
yes, sometimes I do that, but other times it's quicker to just scroll. for example, sometimes I have a person that I need to find a church that is closest to their home. I sort by zip and in two seconds I have x number of churches with that zip. Sometime zip is only last number different.What is wrong with a simple Find then?
Or if you need to search on more than one control, create a search Form for the most searched controls?