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

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.
seanlhallAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jeffrey CoachmanMIS LiasonCommented:
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
Paolo SantiangeliConsulente InformaticoCommented:
Hi,
tblsubjects is a linked table?
why are u using odbc?
0
seanlhallAuthor Commented:
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
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

seanlhallAuthor Commented:
Yes tblesubjects is a linked table on a SQL server, Access is the front end.
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
"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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
"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
Paolo SantiangeliConsulente InformaticoCommented:
are there any relation between the record in the main form and the tblsubjects?
0
seanlhallAuthor Commented:
"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
seanlhallAuthor Commented:
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
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
And the Form UnLoad ?

mx
0
seanlhallAuthor Commented:
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
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
"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
seanlhallAuthor Commented:
Should I put DoCmd.RunCommand acCmdSaveRecord in the Close event?
0
seanlhallAuthor Commented:
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
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
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
seanlhallAuthor Commented:
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
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Actually, I would use Me.Dirty = False

mx
0
seanlhallAuthor Commented:
Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.