Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-09-29
18
Medium Priority
?
292 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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 …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

926 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