access2010
Registered User.
- Local time
- Today, 07:03
- Joined
- Dec 26, 2009
- Messages
- 1,115
Private Sub Clear_Investigate_Yes_Click()
' Fuction Name ===> In the field Investigate, Change "Yes" => "No"
' Table Name ==> update Investments01_tbl
' Field Name ==> investigate
' Change Data in Field Investigate, from Yes to No
''CurrentDb.Execute "update Investments01_tbl" & _
'' "set investigate = 'No' " & _
'' "where Investmentl_ID in (SELECT Investmentl_ID from (" & Replace$(Me.RecordSource, ";", "") & "));"
CurrentDb.Execute "UPDATE Investments01_tbl SET Investments01_tbl.Investigate = 'No' " & _
"WHERE (((Investments01_tbl.Investigate)='Yes'));"
Me.Requery
End Sub
CurrentDb.Execute "update Investments01_tbl" & _
"set investigate = 'No' " & _
"where Investmentl_ID in (SELECT Investmentl_ID from (" & Replace$(Me.RecordSource, ";", "") & "));"
strSQL = "update Investments01_tbl" & _
" set investigate = 'No' " & _
" where Investmentl_ID in (SELECT Investmentl_ID from (" & Replace$(Me.RecordSource, ";", "") & "));"
Debug.Print strSQL
'CurrentDB.Execute strSQL
Thank you Bob for your suggestion, we have tried to use your suggested code in our Access 2003 database without success. The error message that we get is //Try:
Code:Private Sub Clear_Investigate_Yes_Click() ' Fuction Name ===> In the field Investigate, Change "Yes" => "No" ' Table Name ==> update Investments01_tbl ' Field Name ==> investigate ' Change Data in Field Investigate, from Yes to No ''CurrentDb.Execute "update Investments01_tbl" & _ '' "set investigate = 'No' " & _ '' "where Investmentl_ID in (SELECT Investmentl_ID from (" & Replace$(Me.RecordSource, ";", "") & "));" CurrentDb.Execute "UPDATE Investments01_tbl SET Investments01_tbl.Investigate = 'No' " & _ "WHERE (((Investments01_tbl.Investigate)='Yes'));" Me.Requery End Sub
= = =Your problem is in this SQL string, which is in the Click_Event code for the example button in your sample database.
Code:CurrentDb.Execute "update Investments01_tbl" & _ "set investigate = 'No' " & _ "where Investmentl_ID in (SELECT Investmentl_ID from (" & Replace$(Me.RecordSource, ";", "") & "));"
When I attempt to examine Me.RecordSource, it is empty. Your syntax error is that your SELECT sub-query HAS no recordsource. Tracing that back, the form Analytics_F has an EMPTY .RecordSource property.
Marylyn, it seems to me that you have had this problem before. For instance,
Change field name from Yes to No
Could I please receive assistance on how to change the field contents of the field = Investigate = in our Access 2003 Db, if it contains the word =Yes= to = No = by clicking the button = Clear Investigate = The Form = Investments_StockBrowse_F_As_Report = WORKS The Form = MainMenu = is not...www.access-programmers.co.uk
You were previously advised of this same exact problem but don't seem to want to fix it. Well, if you don't do something to fix it, you aren't going to make any progress. It seems like you don't understand that to use Me.RecordSource in any context, the form in question has to be bound to something - and in your example database it is not. That property is EMPTY.
The specific syntax error in this case is that the sub-query after performing the concatenation noted reads (SELECT Investment_ID from ())
and that just is NOT going to work. You are, in effect, asking Access to select data from nowhere. Access doesn't pluck numbers from out of thin air unless your table is NAMED [Thin Air].
Thanks Bob for your note about the cross posting, which will not happen again. I / we are under a pressure at the charity as all of their reports have to be completed by December 29th and little things like changing the field name from Yes to No are slowing us down.
Thank you Gasman for your suggestion, BUT for some reason they do not work on the new Access 2003 form we tried to create. We will go back to using an OLD form that works. Your suggestions are appreciated.All of which could be identified if you put it all into a string variable and just Debug.Print the variable before even trying to use it?
I always put spaces at the front of the next string,(saves having to scroll all the way to the right to see if one is there? ), but do not use continuation much, preferring concatenation
Code:strSQL = "update Investments01_tbl" & _ " set investigate = 'No' " & _ " where Investmentl_ID in (SELECT Investmentl_ID from (" & Replace$(Me.RecordSource, ";", "") & "));" Debug.Print strSQL 'CurrentDB.Execute strSQL
Thank you cheekybuddha for your note, which I appreciate. I was trying to find a solution to the reports the Charity needed completed by Dec 29th.@access2010 / Marylyn - there is no problem with cross-posting.
It just helps (a lot) if you take the extra minutes to explain you have done so and add the links to the cross-posts.
Actually, it is likely to save you more time than those extra minutes in the long run, since folk have the opportunity to build on the posts in the other threads rather than risk repeating the same stuff.
Have a great Christmas/holidays!![]()
![]()
= = =
Thank you The_Doc_Man for your comments. We are volunteers at a charity helping to run their office. The code that we tried to transfer to a new form does NOT work, while it does work on their OLD forms.
So I will use the old forms.
Thank you, Marylyn
You cannot seem to help yourself no matter how many times we tell you exactly what the problem is. We can't fix it for you since we do not have enough information. You have never answered any question that would lead us to be able to solve the problem. You also don't seem capable of following the simplest of directions or understanding any technical concept that would help you to resolve the problem yourself. The problem is and has ALWAYS been that you are using an unbound form (no recordsource) and using code that references the non-existent recordsource. We have told you that and have asked how to determine the selection criteria by NOT pointing to a non-existent recordsource and have gotten no usable answer.Any assistance will be appreciated.