Solved

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

Posted on 2011-09-29
18
281 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: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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

829 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