Access stucks in BeforeUpdate

  • Thread starter Thread starter liya.tansky
  • Start date Start date
L

liya.tansky

Hello,
I'm moving an Access application to .net +sql server.
First step is to make Access front-end for sql server.
I've moved the tables to the SQL Server and linked them through ODBC.
Mostly it works alright, but ometimes it stucks. It happens like this:
all records on the forms have BeforeUpdate that call SaveChanges
function and it displays "changes ok" message box. Only sometimes it
doesn't get to the message and is stuck.
The strange things are that it happens only once in a while and
sometimes works ok on the same record. And the strangest is that if it
is stuck, but I run some over Access application it continues working
and shows no errors and no sign of problems.

Please help
PS I might crosspost this, sorry. but it is very urgent wince this is
my new job
 
Sounds tricky. One thing I would say is that it's possible that you're
confusing the program. The before update routine will run before it's
attempting to save data, and you're telling it to run a SaveChanges routine
while it's doing that. That doesn't really make a great deal of sense -
i.e. it sounds like you're telling it: "before you save the changes, save
the changes". So first thing that I would do would be to review why you're
doing things that way, and maybe post back here again with whatever it is
that you're trying to achieve.
 
The code isn't mine, I'm trying to keep it as it is till I have a
chance o move it to .net.
SaveChanges only displays a messagebox asking if the user agrees to the
change in the data. the name isn't good but it is called from the
correct place
 
Hello,
I'm moving an Access application to .net +sql server.
First step is to make Access front-end for sql server.
I've moved the tables to the SQL Server and linked them through ODBC.
Mostly it works alright, but ometimes it stucks. It happens like this:
all records on the forms have BeforeUpdate that call SaveChanges
function and it displays "changes ok" message box. Only sometimes it
doesn't get to the message and is stuck.

Care to post your code, including the code in SaveChanges? You can see
the code; we cannot.

John W. Vinson[MVP]
 
I'd suspect that the message box is displaying, but hidden in some way.
Probably (i.e. I'm guessing) caused by Access saving data to an mdb and an
ODBC SQL connection in slightly different ways.

Thinking about it, I really don't like the idea of calling "Do you want to
save" messages in the before update. And, to get rid of the error, you're
going to have to change the code somewhere. I'd move the message box to
whatver event(s) actually triggers the save.

(...and, by the way, moving the db to .Net is going to mean a wholesale
rewrite of code. There's little point in trying to avoid changes now.)
 
The code is lke this:
Sub SaveChange()
If Me.NewRecord Or Me.AppNew.Value = -1 Then
Exit Sub
End If
If MsgBox("Are you sure ...?", vbYesNo, "EMS") = vbNo Then
Me.Undo
End If
End Sub
 
Back
Top