Solved

What is the proper way to set the Record Source of a pop up form?

Posted on 2011-09-29
18
276 Views
Last Modified: 2012-05-12
I have a main form which the record source is a query based on a table called tblsubjects . On the main form a commnad button opens up a pop up form that has a notes field, the pop up form record source is also tblsubjects. The problem is some times after opening the pop up form and entering or editing notes when closign the pop up I get the following error.

ODBC--update on a linked table"tblsubjects" falied.
[Microsoft][ODBC Server Driver]Timeout Expired(#0)

Changing the time out has not prevented the error from happing a random times.
0
Comment
Question by:seanlhall
  • 9
  • 6
  • 2
  • +1
18 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36816697
Then you seem like you are trying to edit a record in the popup form that is already open in the main form.

Try saving the record in the main form before opening the popup:

DoCmd.RunCommand acCmdSaveRecord
Docmd.Openform "FrmPopup"......etc.

(you may also need to requery the main form when the popup closes, but this might open up a whole new can of worms...)
0
 
LVL 11

Expert Comment

by:psantiangeli
ID: 36816722
Hi,
tblsubjects is a linked table?
why are u using odbc?
0
 

Author Comment

by:seanlhall
ID: 36816724
I have this before opening pop up form. Is that the same or maybe this is the problem?

If Me.Dirty Then Me.Dirty = False
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
0
 

Author Comment

by:seanlhall
ID: 36816729
Yes tblesubjects is a linked table on a SQL server, Access is the front end.
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 500 total points
ID: 36816809
"I have this before opening pop up form. Is that the same or maybe this is the problem?"
You only need

Me.Dirty = False ' save the record

The 2nd line is redundant ... and all the DoMenuItem commands were depreciated more than 10 years ago and not recommended for use.

mx
0
 
LVL 75
ID: 36816819
"when closign the pop up I get the following error."
Do you have any code in the Form Load or Close event of the popup form ?

mx
0
 
LVL 11

Expert Comment

by:psantiangeli
ID: 36816845
are there any relation between the record in the main form and the tblsubjects?
0
 

Author Comment

by:seanlhall
ID: 36816887
"are there any relation between the record in the main form and the tblsubjects? "

The main form is based on tblsubjects the popup is used becuase there is not enough room on the form for the notes field which is also from tblsubjects.
0
 

Author Comment

by:seanlhall
ID: 36816895
DatabaseMX: I took out the DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70  and now I just have DoCmd.RunCommand acCmdSaveRecord

There is no code on the Form Load or Close.
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 75
ID: 36816910
And the Form UnLoad ?

mx
0
 

Author Comment

by:seanlhall
ID: 36816980
Nothing. The only code is in The Timer Event.  What should I have something in the Load Close or Unload Events.?

Private Sub Form_Timer()
If Datediff("s", Me.Text5, Now) > 300 Then
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close
End If
End Sub
0
 
LVL 75
ID: 36817058
"What should I have something in the Load Close or Unload Events.?\"
I was just asking if there was some.

What happens if you comment out that Timer code?

mx
0
 

Author Comment

by:seanlhall
ID: 36817102
Should I put DoCmd.RunCommand acCmdSaveRecord in the Close event?
0
 

Author Comment

by:seanlhall
ID: 36817112
mx

the form closes on the Timer but I have not received the ODBC error form that because that is rarley used by the user.
0
 
LVL 75
ID: 36817113
No ... And I thought those save commands were in the form that Opens the popup?

Close the form should ... automatically save the record.

mx
0
 

Author Comment

by:seanlhall
ID: 36817128
ok. I am testing with the DoCmd.RunCommand acCmdSaveRecord in place of the Dirty=false and the older DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, so far so good.
0
 
LVL 75
ID: 36817138
Actually, I would use Me.Dirty = False

mx
0
 

Author Closing Comment

by:seanlhall
ID: 36817223
Thanks.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now