Link to home
Start Free TrialLog in
Avatar of Rajesh_Vijayan
Rajesh_Vijayan

asked on

DoEvents??

Iam updating table from datagrid manually. what happens is database is not updated on first save click. If i click again it updates.But when iam in debug mode, it updates on the first save click itself.Or else if i have  a message box popping up during save then also it is updated.
I tried to put the DoEvents before the update command but it did not work. can anyone suggest some solution.
thanks for any help,
Avatar of ronenr
ronenr
Flag of Mexico image

How are you updating your database? Are you using ADO?, post some code!
Avatar of Ryan Chong
To 'pause' the application for certain periods:

Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

· dwMilliseconds
Specifies the time, in milliseconds, for which to suspend execution. A value of zero causes the thread to relinquish the remainder of its time slice to any other thread of equal priority that is ready to run. If there are no other threads of equal priority ready to run, the function returns immediately, and the thread continues execution. A value of INFINITE causes an infinite delay.

Example:

'Do the updates
Sleep 1000
'Continue the process

Hope this help
Avatar of Rajesh_Vijayan
Rajesh_Vijayan

ASKER

Thanks , Let me just check out the option and will let u know immediately.
and,iam using ado to update database.
hi,
iam still facing same problem, maybe iam going wrong in my coding part. so i will make it more clear.
i have 2 tables, master and detail.
master table has name of all screens in my application.
detail table has to have screen names and update , delete flags based on the rights(1 or 0) given by admin.
and the datagrid has to show fields from both tables,that is all the screen names plus, the update and delete flag.
so i have a masterRs recordset opened using both tables, using Left Outer Join.
Then i have set the masterrs.activeconnection= nothing.
Then when i insert the 1 or 0 into datagrid and click save button for each record i call a save or modify data function.
in save function,
--i open a new detailRs recordset using Detail table.
--then i assign the MasterRs fields that have been changed to DetailRs.
hi,
iam still facing same problem, maybe iam going wrong in my coding part. so i will make it more clear.
i have 2 tables, master and detail.
Master     Detail
screenid   screenid
           updateflag
           deleteflag
 
master table has name of all screens in my application.
detail table has to have screen names and update , delete flags based on the rights(1 or 0) given by admin.
and the datagrid has to show fields from both tables,that is all the screen names plus, the update and delete flag.
so i have a masterRs recordset opened using both tables, using Left Outer Join.
Then i have set the masterrs.activeconnection= nothing.
Then when i insert the 1 or 0 into datagrid and click save button for each record i call a save or modify data function.
in save function,
--i open a new detailRs recordset using Detail table.
--then i assign the MasterRs fields that have been  changed  to DetailRs.
--theni update and call the refreshing function to again refresh the MAsterRs recordset.
but then when i try to load data for the user, it is not saved.!!i gave a msgbox function just before calling update function, then data is saved.
sleep function is also not helping me out .
any idea?
Any codes available?

regards

here on click event i call the update and insert fnction
If Mode = "Modify" Then
            Data_UpdateGrid
ElseIf Mode = "Create" Then
            Data_InsertGrid
End If

then in insert function i open new detailrs recordset.
detailrs .AddNew
detailrs !ScreenID = MasterRs!ScreenID
detailrs !UpdateFlag = MasterRs!UpdateFlag
detailrs !DeleteFlag = MasterRs!DeleteFlag
detailrs .Update
MasterRsRefresh   'function call for opening MasterRs  
                   'recordset again

same way for update, i delete the corresponding record first and then insert it again.

and in MasterRsRefresh function, Iam just fetching fields from both master and detail tables.
then when i load the records again, i set the MasterRs.activeconnection= nothing .
hope u have got my point now?
thnks,
pls. its a bit urgent, cud some one help me out?
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hi
sorry for delay. i tried it out, but still the same old thing happens.  it is not getting updated.so i think i'll have to use the message box itself.
Besure the DataGrid is AllowUpdate.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in Community Support that this question is:
- points to ryancys
Please leave any comments here within the
next seven days.
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange