473,320 Members | 2,048 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,320 software developers and data experts.

Form Does Not Return when Changes Made - Instead Locks up Database

64 64KB
Hi Twinnyfo,

Thank you very much for replying. Tried your suggestion and it now returns from the frm_traject_details to frm_trajecten but the the program does not react to anything anymore.

The only thing i can then do is stop the program and restart it...


Any suggestions on how to proceed?
Aug 27 '14 #1
7 1294
twinnyfo
3,653 Expert Mod 2GB
Hmmm.... That sounds like something more than what we began with!

It sounds like there is a problem with the form frm_trajecten.

Does the system hang immediately upon going to frm_trajecten? You can step through the code to determine exactly what point the system is hanging....
Aug 27 '14 #2
zmbd
5,501 Expert Mod 4TB
[[Edit]]
1) Split from thread
http://bytes.com/topic/access/answer...ased-record-nr
[[Edit]]

Posted code original message line 26 duplicates line 29.
Delete Line 26
-
Lines 5 thru 12 are still encodeing for a Macro, I'll have to think about that
-
Copy Line 2 over the current line 13 to re-enable the error trapping.
-
Please run menu>debug>compile
(refer to the following link for basic trouble shooting steps and how to set your options (^_^) > Before Posting (VBA or SQL) Code )
>>> You will have to repeat the compile step until it returns no errors as it stops on the very first error found.
Aug 27 '14 #3
Pierkes
64 64KB
Hi Twinnyfo and ZMB,

Thanks for helping me.
I changed the code with your suggestions ZMBD and it now looks like;

Expand|Select|Wrap|Line Numbers
  1. Private Sub tr_naam_traject_Click()
  2. On Error GoTo tr_naam_traject_Click_Err
  3.     On Error Resume Next
  4.     If (Form.Dirty) Then
  5.         DoCmd.RunCommand acCmdSaveRecord
  6.     End If
  7.     If (MacroError.Number <> 0) Then
  8.         Beep
  9.         MsgBox MacroError.Description, vbOKOnly, ""
  10.         Exit Sub
  11.     End If
  12.     On Error GoTo tr_naam_traject_Click_Err
  13.     DoCmd.OpenForm "frm_traject_details", acNormal, "", "[ID_traject]=" & Nz(ID_traject, 0), , acDialog
  14.     If (Not IsNull(ID_traject)) Then
  15.         TempVars.Add "CurrentID", ID_traject.Value
  16.     End If
  17.     If (IsNull(ID_traject)) Then
  18.         TempVars.Add "CurrentID", Nz(DMax("[ID_traject]", Form.RecordSource), 0)
  19.     End If
  20.     DoCmd.Requery ""
  21.     DoCmd.SearchForRecord , "", acFirst, "[ID_traject]=" & TempVars!CurrentID
  22.     TempVars.Remove "CurrentID"
  23.  
  24.     Exit Sub
  25.  
  26. tr_naam_traject_Click_Err:
  27.     MsgBox Error$
  28.     Exit Sub
  29.  
  30. End Sub
  31.  
The code makes sure i go to the form [frm_traject_details].
When i do not change anything in that form and go back to de form [frm_trajecten] it works fine and i can then select another record to go to by clicking the hyperlink (which is the name of the client).

However, when i change anything on the form [frm_traject_details], the program goes back to the form frm_trajecten and when it displays the form, it completely freezes. Only way out then is shut down ms access and start it again.

Now what ? Any suggestions are very welcome !

For your info, here are all the events of the form frm_trajecten;


Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Me.cmb_AM = "*"
  3. Me.cmb_soort_traject = "*"
  4. Me.cmb_resultaat = "5"
  5. Me.cmb_ad = "*"
  6. Me.cmb_prodjr = "*"
  7. Me.cmb_holding = "*"
  8. Me.cmb_dam = "*"
  9. Me.cmb_ORG = "*"
  10. Me.Requery
  11. End Sub
  12.  
Because it is a split form, i use the upper part to give the user ways to select the correct data that is then displayed in the lower part of the form. In the lower part of the for, the names of the clients (with hyperlinks) etc. will appear.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2. OpenAllDatabases True
  3. End Sub
  4.  
To make sure the backed databases are opened.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Close()
  2. OpenAllDatabases False
  3. End Sub
  4.  
This is the module;
Expand|Select|Wrap|Line Numbers
  1. Sub OpenAllDatabases(pfInit As Boolean)
  2.   ' Open a handle to all databases and keep it open during the entire time the application runs.
  3.   ' Params  : pfInit   TRUE to initialize (call when application starts)
  4.   '                    FALSE to close (call when application ends)
  5.   ' Source  : Total Visual SourceBook
  6.  
  7.   Dim x As Integer
  8.   Dim strName As String
  9.   Dim strMsg As String
  10.  
  11.   ' Maximum number of back end databases to link
  12.   Const cintMaxDatabases As Integer = 2
  13.  
  14.   ' List of databases kept in a static array so we can close them later
  15.   Static dbsOpen() As DAO.Database
  16.  
  17.   If pfInit Then
  18.     ReDim dbsOpen(1 To cintMaxDatabases)
  19.     For x = 1 To cintMaxDatabases
  20.       ' Specify your back end databases
  21.       Select Case x
  22.         Case 1:
  23.           strName = "M:\AIPENS\SATDbe.accdb"
  24.       End Select
  25.       strMsg = ""
  26.  
  27.       On Error Resume Next
  28.       Set dbsOpen(x) = OpenDatabase(strName)
  29.       If Err.Number > 0 Then
  30.         strMsg = "Trouble opening database: " & strName & vbCrLf & _
  31.                  "Make sure the drive is available." & vbCrLf & _
  32.                  "Error: " & Err.Description & " (" & Err.Number & ")"
  33.       End If
  34.  
  35.       On Error GoTo 0
  36.       If strMsg <> "" Then
  37.         MsgBox strMsg
  38.         Exit For
  39.       End If
  40.     Next x
  41.   Else
  42.     On Error Resume Next
  43.     For x = 1 To cintMaxDatabases
  44.       dbsOpen(x).Close
  45.     Next x
  46.   End If
  47. End Sub
  48.  
Any ideas where things go wrong ?
Thanks very much for thinking with me !
Pierkes
Aug 27 '14 #4
zmbd
5,501 Expert Mod 4TB
1) Split from thread
http://bytes.com/topic/access/answer...ased-record-nr

2) It is very importaint that we understand what you are doing here:
Because it is a split form,
The term split form when it comes to ACC2007 and newer refers to: http://office.microsoft.com/en-us/ac...010075994.aspx
What this does is displays the SAME recordset in two ways.
The first way is as an individual record.
The second way is as a datatable.
Usually this form is created by the splitform wizard.... is this how you created the form?

3) Insert a stop command in your "Sub tr_naam_traject_Click" code between lines 2 and 3.

Run your form as normal and see if you can get the application to "lock"

Most likely the debuger will open with that stop command highlighted. Using the [F8] function key, "step" slowly thru your code until you get to the line that appears to "lock" your database.
Aug 27 '14 #5
Pierkes
64 64KB
Hi zmbd,

Tried your suggestion but i do not get an error message when starting the form frm_traject_details.

However, i saw that when the frm_traject_details is opened, the main form frm_trajecten is "locked" or "not accassible" the form's name tab is less highlighted, indicating you cannot work with the form.

When frm_traject_details is closed, frm_trajecten should be accessible again, but it is not.

How can i make sure, that frm_trajecten is accassible again.
(te be clear, the program does not seem to lock up, but the form frm_trajecten still thinks another form is open so i cannot work with it ?)

I hope this is a little more clear and you can help me ?,
Pierkes
Aug 28 '14 #6
zmbd
5,501 Expert Mod 4TB
1) Please take a momement to read #2 of my last post.
Are you using a true split form as decribed therein?

2)For form {frm_trajecten}
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Close() 
  2. OpenAllDatabases False 
  3. End Sub 
  4.  
Place a STOP command before the call to OpenAllDatabases
Run as you would and see if this code is executing after you open the form {frm_traject_details} - it shouldn't be.

3) Have you provided all of the code behind {frm_traject_details} that refers to {frm_trajecten}?
Aug 28 '14 #7
Pierkes
64 64KB
Hi zmbd,

Turns out that i was looking in the wrong place....ouch !

On the frm_traject_details form i have a button to close the form and go back to the frm_trajecten form.

This was the code;

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdClose_Click()
  2. On Error GoTo cmdClose_Click_Err
  3.  
  4.     On Error Resume Next
  5.  
  6.     If Me![Status Res] <> 5 And Me![Soort traject] < 6 And Me![chk_reden] = False Then
  7.         MsgBox ("Het resultaat van dit traject is " & [Status Res].Column(1) & ", geef aan wat de reden(en) hiervoor zijn aub!")
  8.         Me![Redenen van winst of verlies].Form![cmb_reden_cat].SetFocus
  9.     Cancel = True
  10.     Exit Sub
  11.  
  12.     End If
  13.  
  14.     If (Form.Dirty) Then
  15.        DoCmd.RunCommand acCmdSaveRecord
  16.     End If
  17.  
  18.     If (MacroError.Number <> 0) Then
  19.       Exit Sub
  20.     End If
  21.     If Not Me.Dirty Then
  22.     DoCmd.Close , ""
  23.     End If
  24.  
  25. cmdClose_Click_Exit:
  26.     Exit Sub
  27.  
  28. cmdClose_Click_Err:
  29.     MsgBox Error$
  30.     Resume cmdClose_Click_Exit
  31.  
  32. End Sub
  33.  
Turns out that the if statement caused the trouble.
No i moved the if statement to the beforUpdate event;

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_beforeupdate(Cancel As Integer)
  2. DoCmd.Echo True
  3. Dim ctl As Control
  4.  
  5. If Me![Status / Resultaat] <> 5 And Me![soort traject] < 6 And Me![chk_reden] = False Then
  6. MsgBox ("Het resultaat van dit traject is " & [Status / Resultaat].Column(1) & "," & vbCrLf & "geef aan (in het tabje 'Status en resultaat' wat de redenen hiervoor zijn aub!")
  7. Me![Redenen van winst of verlies].Form![cmb_reden_cat].SetFocus
  8. Cancel = True
  9. Exit Sub
  10. End If
  11.  
  12. DoCmd.Echo False
  13. End Sub
  14.  
Now it generates a nice message, sets focus to the right control and when the form eventually closes, there is no problem anymore...

pfff....what a journey.
Thank you very much for your help !

Pierkes
Aug 28 '14 #8

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

Similar topics

1
by: Martin Williams | last post by:
I have a main form with a bound combobox. I then have another form which is accessed from the main form, which I used to update the data that is bound to the combobox. I know how to update a...
2
by: Brian Hoops | last post by:
I have a windows forms datagrid and I would like to be able to recognize when changes have been made in order to perform the update. I tried the following, which works well, but only if the user...
1
by: eljainc | last post by:
Hello, I have a program written in C#.NET VS2005 that accesses a SQL database/data table through a dataset. It was decided that a valued defined as a smallint in SQL Server should be changed to...
6
by: mike11d11 | last post by:
I'm trying to create an application that will have multiple users working off a table on a SQL server. Since multi users will be updating different records at any given moment, how can i get those...
1
by: mankolele | last post by:
Hi all Is there someway to track changes made to data in a mysql database? Like someone changes a phone number in a record on a form -Is there a way to find out what changes were made to what...
6
by: lucyh3h | last post by:
Hi, In one of my pages, I use javascript (AJAX) to populate one mulitple select field based on user's click event on another control. I noticed that when I navigate back to this page by clicking...
3
by: =?Utf-8?B?QnJhbmRvbg==?= | last post by:
Hi, I have an aspx page that has the "include" code in it which includes another page that displays information. I also have an upload page that allows users to upload a simple html document...
1
by: =?Utf-8?B?QnJhbmRvbg==?= | last post by:
Hi, I have an aspx page that contains an include section which calls an html page for text to be displayed on the aspx page. I also have an upload page that allows users to upload a simple html...
5
by: vovan | last post by:
I have set of controls (Textboxes, checkboxes etc) along with the Grid on Windows Form. I use BindingSource to populate both Grid and the set of Controls. User selects the record in the grid and...
1
by: amitjaura | last post by:
Well i have a datagridview in my application and i want it to reflect any changes made in server database instantly with some trigger or so? I have a choice to use timer and get the desired results...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.