473,414 Members | 1,776 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Unable to run Update Query...Please Help

Hello experts,

I have an update query that I want to modify records meeting a certain criteria in a table based on information on a form.

I am having trouble recognizing the table for a comparison to text box on the form.

Table Name: Created_Submitted
Update Query: Created_Submitted_Update
Text Box: TxtTitle

Expand|Select|Wrap|Line Numbers
  1.  
  2. If Me![TxtTitle] = (Created_Submitted.Title) Then
  3.     Dim stUpdate As String
  4.  
  5.     stUpdate = "Created_Submitted_Update
  6. DoCmd.OpenQuery stUpdate, acNormal, asEdit
  7. End If
  8.  
I am getting the message “Object Required” when I try to run this. I have been away from working on this for a week or so but I have still not been able to get this to work.

As always, any help would be greatly appreciated.

Thanks,
Doug
May 22 '08 #1
5 1934
puppydogbuddy
1,923 Expert 1GB
Doug,
Try changing the following:

this:
If Me![TxtTitle] = (Created_Submitted.Title) Then
to this:
If Me![TxtTitle] = [Created_Submitted.Title] Then

and this:
stUpdate = "Created_Submitted_Update
to this:
stUpdate = "Created_Submitted_Update"
May 22 '08 #2
I did that but I am now getting the message: Microsoft Access can't find the field "|" referred to in your expression.

Expand|Select|Wrap|Line Numbers
  1.       If Me![TxtTitle] = [Created_Submitted.Title] Then
  2.             Dim stUpdate As String
  3.  
  4.             stUpdate = "Created_Submitted_Update"
  5.             DoCmd.OpenQuery stUpdate, acNormal, asEdit
  6.       End If
  7.  
I have also created a query to verify what has not been submitted and then tried comparing the form's text field to the corresponding field in the verify query results. That gave me the same thing.

Ultimately what I need this to do is compare the text field on the form to the Title field in the table and also to determine if the [Submitted To] field in the table is equal to "Not Applicable". If that all matches then I wnat to run the update query to modify that particular record in the table. If not then it will run an append query. The append query is working fine but there are no comparisons between the form and the table for that one.

Thanks,
Doug
May 22 '08 #3
puppydogbuddy
1,923 Expert 1GB
Can't tell where error msg is coming from. Can you pinpoint the error line?

Try changing this:
If Me![TxtTitle] = [Created_Submitted.Title] Then
to this:
If Me![TxtTitle] = [Created_Submitted].[Title] Then


or this:
If Me![TxtTitle] = [Title] Then
May 22 '08 #4
This is the entire active code for that event:

Expand|Select|Wrap|Line Numbers
  1. Private Sub CMD_AddRecord2_Click()
  2. On Error GoTo Err_CMD_Add_Record2_Click
  3.  
  4. If [Forms]![Poetry]![TxtTitle] = [Created_Submitted].[Title] Then
  5. Dim stUpdate As String
  6.  
  7. stUpdate = "Created_Submitted_Update"
  8. DoCmd.OpenQuery stUpdate, acNormal, asEdit
  9. End If
  10.  
  11. Exit_CMD_Add_Record2_Click:
  12. Exit Sub
  13.  
  14. Err_CMD_Add_Record2_Click:
  15. MsgBox Err.Description
  16. Resume Exit_CMD_Add_Record2_Click
  17.  
  18. End Sub
  19.  
I can't seem to step through it to see where it is failing. I tried your suggestions and also repolaced Me![TxtTitle] with [Forms]![Poetry]![TxtTitle]. None of them worked.

Someone pointed me to some CheckFilter code but whan I tried that it didn't work either. I'm pretty sure I had it all setup wrong though.
May 22 '08 #5
puppydogbuddy
1,923 Expert 1GB
This is the entire active code for that event:

Expand|Select|Wrap|Line Numbers
  1. Private Sub CMD_AddRecord2_Click()
  2. On Error GoTo Err_CMD_Add_Record2_Click
  3.  
  4. If [Forms]![Poetry]![TxtTitle] = [Created_Submitted].[Title] Then
  5. Dim stUpdate As String
  6.  
  7. stUpdate = "Created_Submitted_Update"
  8. DoCmd.OpenQuery stUpdate, acNormal, asEdit
  9. End If
  10.  
  11. Exit_CMD_Add_Record2_Click:
  12. Exit Sub
  13.  
  14. Err_CMD_Add_Record2_Click:
  15. MsgBox Err.Description
  16. Resume Exit_CMD_Add_Record2_Click
  17.  
  18. End Sub
  19.  
I can't seem to step through it to see where it is failing. I tried your suggestions and also repolaced Me![TxtTitle] with [Forms]![Poetry]![TxtTitle]. None of them worked.

Someone pointed me to some CheckFilter code but whan I tried that it didn't work either. I'm pretty sure I had it all setup wrong though.
Doug,
Your code above looks ok, but try placing brackets around "[Created_Submitted_Update]" and see what happens. If that does not work, try this:

Instead of doing the check of the form entry against the table in the above code, do it in the Update query itself.......that is, go to your query [Created_Submitted_Update] and drag TxtTitle again from table area to the query grid and in the criteria row of TxtTitle put....... = [Forms]![Poetry]![TxtTitle]

Then change your code to look like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub CMD_AddRecord2_Click()
  2. On Error GoTo Err_CMD_Add_Record2_Click
  3.  
  4.  
  5. Dim stUpdate As String
  6.  
  7. stUpdate = "Created_Submitted_Update"
  8. DoCmd.OpenQuery stUpdate, acNormal, asEdit
  9.  
  10.  
  11. Exit_CMD_Add_Record2_Click:
  12. Exit Sub
  13.  
  14. Err_CMD_Add_Record2_Click:
  15. MsgBox Err.Description
  16. Resume Exit_CMD_Add_Record2_Click
  17.  
  18. End Sub
  19.  
May 22 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: m3ckon | last post by:
Hi there, I'm a little stuck and would like some help I need to create an update trigger which will run an update query on another table. However, What I need to do is update the other...
3
by: RichG | last post by:
I have a new computer that has a new instalation of XP Pro then a new install of XP Office then a new XP SP2 install. I just downloaded EN_VS.NET_ENT_DEV_FULL.exe into c:\Temp and extracted it...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
4
by: John Baker | last post by:
Hi: I have two tables, a setup table (TblSetup) and a purchase order table (tblPO). When i construct a query with ONLY the tblPO shown, and a type in parameter for the PO number, I an update...
10
by: Randy Harris | last post by:
I imported records into a table, later found out that many of them had trailing spaces in one of the fields. If I'd caught it sooner, I could have trimmed the spaces before the import. This...
1
by: Aaron | last post by:
Hello fellow programmers, I am trying to run an append/update query from code, a command button on a form initiates the queries. the format i am using is; ...
4
by: René Kabis | last post by:
People, I am at my wit's end. I am using the exact code from http://aspnet.4guysfromrolla.com/articles/071002-1.aspx And yet, the code does not manage to update the database. When I go to...
1
by: ammar_fake | last post by:
Hello! I have an Oracle linked server connected through MSDAORA. Linked server queries work perfectly - the "openquery" ones as well as the 4-part-named ones. The problem I have is with...
1
by: sheenaa | last post by:
Hello Members, I m creating my application forms in ASP.Net 2005 C# using the backend SQL Server 2005. What i have used on forms :: ? On my first form i have used some...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.