Solved

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

Posted on 2011-09-29
18
283 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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:Paolo Santiangeli
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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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 - Microsoft MVP, Access and Data Platform) 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:Paolo Santiangeli
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
 
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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

751 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