473,395 Members | 1,996 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,395 software developers and data experts.

problem with UPDATE statement

40
Hello,
I have a problem with update statement
Expand|Select|Wrap|Line Numbers
  1. CurrentDb.Execute ("UPDATE PRACOWNICY " & _
  2.                        "SET [NAZWISKO]='" & Me!txtNazwiskoNew & "' And " & _
  3.                        "[IMIE]='" & Me!txtImieNew & "' And " & _
  4.                        "[ID_STANOWISKA]=" & Me!txtStanowisko & " " & _
  5.                        "WHERE GEID=" & Me!txtGeid)
I debugged it and Me!txtNazwiskoNew is set to "-1" when nothing is changed and acts like it should if there was some change. Then it skips to next record and I don't want that.I also get msgbox "Another user edited this record blah blah blah" and I don't want that either. Any idea how to fix it?
Aug 8 '07 #1
5 1348
puppydogbuddy
1,923 Expert 1GB
Hello,
I have a problem with update statement
Expand|Select|Wrap|Line Numbers
  1. CurrentDb.Execute ("UPDATE PRACOWNICY " & _
  2.                        "SET [NAZWISKO]='" & Me!txtNazwiskoNew & "' And " & _
  3.                        "[IMIE]='" & Me!txtImieNew & "' And " & _
  4.                        "[ID_STANOWISKA]=" & Me!txtStanowisko & " " & _
  5.                        "WHERE GEID=" & Me!txtGeid)
I debugged it and Me!txtNazwiskoNew is set to "-1" when nothing is changed and acts like it should if there was some change. Then it skips to next record and I don't want that.I also get msgbox "Another user edited this record blah blah blah" and I don't want that either. Any idea how to fix it?
Try this:
Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2.  
  3. strSQL = "Update [PRACOWNICY] SET [NAZWISKO] = "' & Me!txtNazwiskoNew & "',"
  4. strSQL = strSQL & " [ID_STANOWISKA] = " & Me!txtStanowisko 
  5. strSQL = strSQL & " WHERE [GEID] = " & Me!txtGeid & ";"
  6.  
  7. CurrentDb.Execute strSQL, dbFailOnError
  8. Me.Refresh
  9.  
Aug 8 '07 #2
saddist
40
Try this:
Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2.  
  3. strSQL = "Update [PRACOWNICY] SET [NAZWISKO] = "' & Me!txtNazwiskoNew & "',"
  4. strSQL = strSQL & " [ID_STANOWISKA] = " & Me!txtStanowisko 
  5. strSQL = strSQL & " WHERE [GEID] = " & Me!txtGeid & ";"
  6.  
  7. CurrentDb.Execute strSQL, dbFailOnError
  8. Me.Refresh
  9.  
unfortunatly it isn't working :/ I got rid of annoying msgbox but still if there is no change Me!txtNazwiskoNew is set to "-1"
Aug 8 '07 #3
puppydogbuddy
1,923 Expert 1GB
unfortunatly it isn't working :/
What do you mean by it's not working? Provide details, error messages, what line is highligted, etc.
Aug 8 '07 #4
saddist
40
Like I said. Me!txtNazwiskoNew is set to "-1" after CurrentDb.Execute strSQL, dbFailOnError if no change in Me!txtNazwiskoNew or Me!txtImieNew or Me!txtStanowisko is made
Aug 8 '07 #5
saddist
40
Ok I did the easiest thing I could... If Me.Dirty Then ;) Thanks for help
Aug 8 '07 #6

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

Similar topics

2
by: Bill S. | last post by:
Hi, I am just starting to work with ASP, so bear that in mind... I have an ASP page that displays records from a table, and allows you to add, update and delete. There is a form with one...
3
by: Nicolas Payre | last post by:
Hi, I have the following SQL that I want to use to update a table. It doesn't work ! Does someone knows why? ** I Know it could be done easy with a CURSOR FOR LOOP, but still... Thanks for...
17
by: LineVoltageHalogen | last post by:
Table DDL: create table test ( inId int primary key identity, inFK int not null, inSeq int not null, dtDate datetime )
2
by: Ray | last post by:
I have a list of about 20,000 rows that I am updating. I loop through each row in my program and basically do the following (1) select * from TABLE where SID= for update /*lock the row*/ (2)...
4
by: Mervin Williams | last post by:
I have several tables involved in my application, but the two in question here are the company and address tables. The company table has business_address_id and mailing_address_id columns, which...
5
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
4
by: Jack | last post by:
Hi, I have a asp page where part of the code is as follows. This builds up the sql statement partially. sql01 = "UPDATE EquipmentTbl SET " sql01 = sql01 & "SerialNumber = '" &...
3
by: shark | last post by:
Hi all. i am facing a deadlock problem .i have included the -t1204 and -T3605 trace flags and have got the following o/p pu tin sqls server logs. 2006-06-01 17:49:21.84 spid4 2006-06-01...
2
by: mob1012 via DBMonster.com | last post by:
Hi All, I wrote last week about a trigger problem I was having. I want a trigger to produce a unique id to be used as a primary key for my table. I used the advice I received, but the trigger is...
5
by: Brad Baker | last post by:
I'm trying to write a simple asp.net page which updates some data in a SQL database. At the top of the page I have the following code: <%@ Page Language="C#" Debug="true" %> <%@ import...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.