Popup and Synchronizing

  • Thread starter chopper57 via AccessMonster.com
  • Start date
C

chopper57 via AccessMonster.com

Popup used to add new data such as a Job Site Number doesn't synchronize

When Database is open the Site numbers in the combo box are in ascending
order, and the SubForm goes to the last record. (this is what I want)

MainForm (frm_MainForm) with only one Combo Box to choose a Site Number
SubForm (sfrm_DailyReport) with fields for data.
PopupForm (pfrm_Site) to add new Site Number

(Popup is a second level popup: I have a MainPopup (pfrm_UpdateData) with
cmdbuttons for other Popups to enter data, and it’s the same scenario for
them all)

Popup form works fine when you open the database and you don’t navigate from
the first record shown.

I open the PopupForm enter the new Site number, close PopupForm, choose new
site number from combo on MainForm and the SubForm shows a new record for the
new site.

If I open the database and navigate from the fist Site number to input data
and then decide to add a new Site number this is what happens:

Open PopupForm, add new Site number, close PopupForm, choose newly added Site
number from combo on MainForm and the Subform reverts back to the records of
the fisrt Site number shown when the database is open.

This is the code that I have on the forms:

1. MainForm (frm_MainForm) Code:
Private Sub Combo1_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Site] = '" & Me![Combo1] & "'"
Me.Bookmark = rs.Bookmark
End Sub

Private Sub Form_Current()
DoCmd.GoToControl "sfrm_DailyReport"
DoCmd.GoToRecord , , acLast
End Sub

Private Sub Form_Load()
Me.Combo1 = Me.Combo1.Column(0, 0)
End Sub

2. PopupForm (pfrm_Site) Code:
Private Sub Form_Close()
Forms!frm_MainForm!Combo1.Requery
DoCmd.Close acForm, "pfrm_UpdateData"
‘Closes the main popup when you close the Site popup
End Sub


3. SubForm (sfrm_DailyReport) Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
'Auto increments a sequential number for ReportNo
If Me.NewRecord Then
Me.ReportNo = Format(Nz(DMax("[ReportNo]", "qry12_DailyReport", _
"[Site]=" & "Forms![frm_MainForm]![Combo1]"), 0) + 1, "0000")
End If
End Sub

Private Sub Form_Current()
lblNew.Visible = Me.NewRecord
cboDate = AutoNo
cboReportNo = AutoNo
Date.SetFocus
End Sub

Private Sub Form_Load()
DoCmd.GoToRecord , , acLast
End Sub

Private Sub cmdUpDateData_Click()
'Open main Popup Form
On Error GoTo Err_cmdUpDateData_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "pfrm_UpdateData"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdUpDateData_Click:
Exit Sub
Err_cmdUpDateData_Click:
MsgBox Err.Description
Resume Exit_cmdUpDateData_Click
End Sub

Private Sub Form_Open(Cancel As Integer)
DoCmd.Maximize
End Sub
 
G

Guest

Hi chopper57,

You don't appear to be requerying your main FORM after adding a new record
in your popup. You need to requery the form as well as the combo.

Hope this helps.

Damian.

chopper57 via AccessMonster.com said:
Popup used to add new data such as a Job Site Number doesn't synchronize

When Database is open the Site numbers in the combo box are in ascending
order, and the SubForm goes to the last record. (this is what I want)

MainForm (frm_MainForm) with only one Combo Box to choose a Site Number
SubForm (sfrm_DailyReport) with fields for data.
PopupForm (pfrm_Site) to add new Site Number

(Popup is a second level popup: I have a MainPopup (pfrm_UpdateData) with
cmdbuttons for other Popups to enter data, and it’s the same scenario for
them all)

Popup form works fine when you open the database and you don’t navigate from
the first record shown.

I open the PopupForm enter the new Site number, close PopupForm, choose new
site number from combo on MainForm and the SubForm shows a new record for the
new site.

If I open the database and navigate from the fist Site number to input data
and then decide to add a new Site number this is what happens:

Open PopupForm, add new Site number, close PopupForm, choose newly added Site
number from combo on MainForm and the Subform reverts back to the records of
the fisrt Site number shown when the database is open.

This is the code that I have on the forms:

1. MainForm (frm_MainForm) Code:
Private Sub Combo1_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Site] = '" & Me![Combo1] & "'"
Me.Bookmark = rs.Bookmark
End Sub

Private Sub Form_Current()
DoCmd.GoToControl "sfrm_DailyReport"
DoCmd.GoToRecord , , acLast
End Sub

Private Sub Form_Load()
Me.Combo1 = Me.Combo1.Column(0, 0)
End Sub

2. PopupForm (pfrm_Site) Code:
Private Sub Form_Close()
Forms!frm_MainForm!Combo1.Requery
DoCmd.Close acForm, "pfrm_UpdateData"
‘Closes the main popup when you close the Site popup
End Sub


3. SubForm (sfrm_DailyReport) Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
'Auto increments a sequential number for ReportNo
If Me.NewRecord Then
Me.ReportNo = Format(Nz(DMax("[ReportNo]", "qry12_DailyReport", _
"[Site]=" & "Forms![frm_MainForm]![Combo1]"), 0) + 1, "0000")
End If
End Sub

Private Sub Form_Current()
lblNew.Visible = Me.NewRecord
cboDate = AutoNo
cboReportNo = AutoNo
Date.SetFocus
End Sub

Private Sub Form_Load()
DoCmd.GoToRecord , , acLast
End Sub

Private Sub cmdUpDateData_Click()
'Open main Popup Form
On Error GoTo Err_cmdUpDateData_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "pfrm_UpdateData"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdUpDateData_Click:
Exit Sub
Err_cmdUpDateData_Click:
MsgBox Err.Description
Resume Exit_cmdUpDateData_Click
End Sub

Private Sub Form_Open(Cancel As Integer)
DoCmd.Maximize
End Sub
 
C

chopper57 via AccessMonster.com

Hi Damian, I tried the follow on the close event of the popup form

Private Sub Form_Close()
Forms!frm_MainForm!Combo1.Requery
Forms!frm_MainForm.Form.Requery
DoCmd.Close acForm, "pfrm_UpdateData"
End Sub

I receive an error 2474 The expression you entered requires the control to be
in the active window.

Is there a way to requery the combo and form in one line.


Damian said:
Hi chopper57,

You don't appear to be requerying your main FORM after adding a new record
in your popup. You need to requery the form as well as the combo.

Hope this helps.

Damian.
Popup used to add new data such as a Job Site Number doesn't synchronize
[quoted text clipped - 86 lines]
DoCmd.Maximize
End Sub
 
G

Guest

You have an extra ".form" in there... use

forms!frm_MainForm.Requery

D.


chopper57 via AccessMonster.com said:
Hi Damian, I tried the follow on the close event of the popup form

Private Sub Form_Close()
Forms!frm_MainForm!Combo1.Requery
Forms!frm_MainForm.Form.Requery
DoCmd.Close acForm, "pfrm_UpdateData"
End Sub

I receive an error 2474 The expression you entered requires the control to be
in the active window.

Is there a way to requery the combo and form in one line.


Damian said:
Hi chopper57,

You don't appear to be requerying your main FORM after adding a new record
in your popup. You need to requery the form as well as the combo.

Hope this helps.

Damian.
Popup used to add new data such as a Job Site Number doesn't synchronize
[quoted text clipped - 86 lines]
DoCmd.Maximize
End Sub
 
C

chopper57 via AccessMonster.com

Damian, I tried:
forms!frm_MainForm.Requery

I receive no error but when I select the newly added Site number it still
reverts back to the records of
the fisrt Site number shown when the database is open.



Damian said:
You have an extra ".form" in there... use

forms!frm_MainForm.Requery

D.
Hi Damian, I tried the follow on the close event of the popup form
[quoted text clipped - 23 lines]
 
C

chopper57 via AccessMonster.com

I found something that works, the following is what I have in the close event
of the PopupForm and it let me click on the newly added number in the combo
box adds a new record.

Private Sub Form_Close()
DoCmd.OpenForm "frm_MainForm", WindowMode:=acDialog
Forms!frm_MainForm!Combo1.Requery
Forms!frm_MainForm.Form.Requery
DoCmd.Close acForm, "pfrm_UpdateData"
End Sub

I'm not sure what the WindowMode:=acDialog does but I've seen on some post
with the same problem that I'm having and gave it a shot.
Damian, I tried:
forms!frm_MainForm.Requery

I receive no error but when I select the newly added Site number it still
reverts back to the records of
the fisrt Site number shown when the database is open.
You have an extra ".form" in there... use
[quoted text clipped - 7 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top