Requerying a pop up form to display in the main form

G

Guest

I have a form call Daily Dispatch Log its table is also Daily Dispatch Log.
I have a pop up form "Quick Call" that opens to a new record if I am in the
Daily Dispatch Log and allows me to put another record in with. (Officer,Call
Type, Location, License, State, On Scene). I created the pop up form so if I
was in a call I could quickly add another record with out having to leave the
screen I was in. I need help in setting this pop up form to requery the
information on the Daily Dispatch Log so I am not having to close it out to
see it on the main form "Daily Dispatch Log"

Thanks in advance Jen
 
K

Ken Snell [MVP]

In the code that opens the popup form, after the line that opens the form
(in dialog mode, right?), put a requery step for your current form.

Something like this:
DoCmd.OpenForm "popup form", , , , , acDialog
Me.Requery
 
G

Guest

Okay forgive me I am not that advance with Access YET...
I am not sure what "dialog mode" refers to
 
G

Guest

Okay I have a command button that opens the form. I created a form and
linked the command. I was sure this was considered a pop up form.
 
G

Guest

Okay my pop up is working but the main form that the information goes to is
not updating with the information from the pop up unless I close it and open
it
 
K

Ken Snell [MVP]

As I indicated in my first reply, this can be done by adding a requery step
to the code that is opening the form. Can you post the code that is run when
you click the button to open the popup form?
 
G

Guest

Okay I understand that however I have the main form open all the time it
never closes. The pop form's information is not journaling to the main form
unless I close the main form then I can see it when I reopen it.
 
K

Ken Snell [MVP]

Let me try asking my question in a different way.

In the form that is open all the time, you do something to cause the popup
form to be opened. Click a button? Post the code that runs in order to cause
the popup form to open.

--

Ken Snell
<MS ACCESS MVP>
 
G

Guest

The form that is open is my Daily dispatch Log. It is used to track all
calls. However if i am in the middle of a call I want to press the quick
call button and fill in 5 fields and then close the form. The pop up form
opens to the next availble record in the Daily Dispatch Log. The problem is
when I close the pop up form the Daily Dispatch log goes to record 1 and does
not show that I have added a record. I need it to requery the Daily Dispatch
Log so I can see the call I added with the Quick Call form. Now if I close
the Daily Dispatch Log and reopen it, it shows the record I added.

Jen
 
K

Ken Snell [MVP]

What is the code that runs when you click the "quick call button"? What is
the code that runs in the popup form's Close event and in the "done entering
data" button on the popup form?
 
G

Guest

These are the codes that I have. When I insert the Me.Requery I get an error
message.

Private Sub CmdQuickCall_Click()
On Error GoTo Err_CmdQuickCall_Click

Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.OpenForm "QuickCall", , , , , acDialog
Me.Requery


Exit_CmdQuickCall_Click:
Exit Sub

Err_CmdQuickCall_Click:
MsgBox Err.Description
Resume Exit_CmdQuickCall_Click

End Sub
Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "QuickCall", , , , , acDialog
DoCmd.GoToRecord , , acNewRec
End Sub

Private Sub OnScene_Click()
Me![On Scene] = Now()
End Sub
Private Sub CmdCloseForm_Click()
On Error GoTo Err_CmdCloseForm_Click


DoCmd.Close


Exit_CmdCloseForm_Click:
Exit Sub

Err_CmdCloseForm_Click:
MsgBox Err.Description
Resume Exit_CmdCloseForm_Click

End Sub
Private Sub CmdRefresh_Click()
On Error GoTo Err_CmdRefresh_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70

Exit_CmdRefresh_Click:
Exit Sub

Err_CmdRefresh_Click:
MsgBox Err.Description
Resume Exit_CmdRefresh_Click

End Sub
 
K

Ken Snell [MVP]

It will help us here if you identify which code is in which form...

I am assuming that CmdQuickCall_Click is in the main form (your Daily
Dispatch Log form); and that all the other code is from the popup form (your
QuickCall form)? Is this correct?

What error message do you get from the Me.Requery step?

Are you in the middle of entering/editing a record on the Daily Dispatch Log
form when you click the QuickCall button? It appears that you use the
QuickCall form to enter a new record that is to be displayed on the Daily
Dispatch Log form after it's entered. Is the Daily Dispatch Log form
filtered in any way? Does the QuickCall form have the same filter so that
the entry you make would show on the Daily Dispatch Log form if it had
already been there?

Note that the Me.Requery step will indeed put the form back at the "first"
record. It appears that you want the form to "move" to the newly entered
record (the one entered via the QuickCall form)? If yes, it'll be necessary
for the Daily Dispatch Log form to know what the primary key value is for
the newly entered form. This can be done if you don't close QuickCall form,
but instead make it invisible (after saving its current record), let the
code in the Daily Dispatch Log form read the primary key value from the
QuickCall form, and then have the Daily Dispatch Log form close the
QuickCall form. Then the Daily Dispatch Log form should requery itself
(Me.Requery) and then move to that new record:


Private Sub CmdQuickCall_Click()
Dim PrimKey as Variant
On Error GoTo Err_CmdQuickCall_Click

Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.OpenForm "QuickCall", , , , , acDialog
PrimKey =
Forms("QuickCall").Controls("NameOfControlBoundToPrimaryKeyField").Value
Me.Requery
With Me.RecordsetClone
.MoveFirst
' this code step is used if the primary key is a numeric field
.FindFirst "NameOfPrimaryKeyField = " & PrimKey
' this code step is used if the primary key is a text field
' .FindFirst "NameOfPrimaryKeyField = '" & PrimKey & "'"

' this code step is used if the primary key is a date field
' .FindFirst "NameOfPrimaryKeyField = #" & PrimKey & "#"
If .NoMatch = True Then
MsgBox "cannot find the newly entered record"
Else
Me.Bookmark = .Bookmark
End If
End With

Exit_CmdQuickCall_Click:
Exit Sub

Err_CmdQuickCall_Click:
MsgBox Err.Description
Resume Exit_CmdQuickCall_Click

End Sub


Then the close event procedure in QuickCall would be changed to this:

Private Sub CmdCloseForm_Click()
On Error GoTo Err_CmdCloseForm_Click
Me.Visible = False

Exit_CmdCloseForm_Click:
Exit Sub

Err_CmdCloseForm_Click:
MsgBox Err.Description
Resume Exit_CmdCloseForm_Click

End Sub


Also, this procedure seems to have a redundant step:
Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "QuickCall", , , , , acDialog
DoCmd.GoToRecord , , acNewRec
End Sub

It should be changed to this:
Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
End Sub


--

Ken Snell
<MS ACCESS MVP>


Jennifer P said:
These are the codes that I have. When I insert the Me.Requery I get an
error
message.

Private Sub CmdQuickCall_Click()
On Error GoTo Err_CmdQuickCall_Click

Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.OpenForm "QuickCall", , , , , acDialog
Me.Requery


Exit_CmdQuickCall_Click:
Exit Sub

Err_CmdQuickCall_Click:
MsgBox Err.Description
Resume Exit_CmdQuickCall_Click

End Sub
Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "QuickCall", , , , , acDialog
DoCmd.GoToRecord , , acNewRec
End Sub

Private Sub OnScene_Click()
Me![On Scene] = Now()
End Sub
Private Sub CmdCloseForm_Click()
On Error GoTo Err_CmdCloseForm_Click


DoCmd.Close


Exit_CmdCloseForm_Click:
Exit Sub

Err_CmdCloseForm_Click:
MsgBox Err.Description
Resume Exit_CmdCloseForm_Click

End Sub
Private Sub CmdRefresh_Click()
On Error GoTo Err_CmdRefresh_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70

Exit_CmdRefresh_Click:
Exit Sub

Err_CmdRefresh_Click:
MsgBox Err.Description
Resume Exit_CmdRefresh_Click

End Sub


Ken Snell said:
What is the code that runs when you click the "quick call button"? What
is
the code that runs in the popup form's Close event and in the "done
entering
data" button on the popup form?
 
K

Ken Snell [MVP]

Sorry... I have left out a step in the "new" code that I posted for the
"calling" of the QuickCall form:

Private Sub CmdQuickCall_Click()
Dim PrimKey as Variant
On Error GoTo Err_CmdQuickCall_Click

Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.OpenForm "QuickCall", , , , , acDialog
PrimKey =
Forms("QuickCall").Controls("NameOfControlBoundToPrimaryKeyField").Value
DoCmd.Close acForm, "QuickCall", acSaveNo
Me.Requery
With Me.RecordsetClone
.MoveFirst
' this code step is used if the primary key is a numeric field
.FindFirst "NameOfPrimaryKeyField = " & PrimKey
' this code step is used if the primary key is a text field
' .FindFirst "NameOfPrimaryKeyField = '" & PrimKey & "'"

' this code step is used if the primary key is a date field
' .FindFirst "NameOfPrimaryKeyField = #" & PrimKey & "#"
If .NoMatch = True Then
MsgBox "cannot find the newly entered record"
Else
Me.Bookmark = .Bookmark
End If
End With

Exit_CmdQuickCall_Click:
Exit Sub

Err_CmdQuickCall_Click:
MsgBox Err.Description
Resume Exit_CmdQuickCall_Click

End Sub


--

Ken Snell
<MS ACCESS MVP>

Ken Snell said:
It will help us here if you identify which code is in which form...

I am assuming that CmdQuickCall_Click is in the main form (your Daily
Dispatch Log form); and that all the other code is from the popup form
(your QuickCall form)? Is this correct?

What error message do you get from the Me.Requery step?

Are you in the middle of entering/editing a record on the Daily Dispatch
Log form when you click the QuickCall button? It appears that you use the
QuickCall form to enter a new record that is to be displayed on the Daily
Dispatch Log form after it's entered. Is the Daily Dispatch Log form
filtered in any way? Does the QuickCall form have the same filter so that
the entry you make would show on the Daily Dispatch Log form if it had
already been there?

Note that the Me.Requery step will indeed put the form back at the "first"
record. It appears that you want the form to "move" to the newly entered
record (the one entered via the QuickCall form)? If yes, it'll be
necessary for the Daily Dispatch Log form to know what the primary key
value is for the newly entered form. This can be done if you don't close
QuickCall form, but instead make it invisible (after saving its current
record), let the code in the Daily Dispatch Log form read the primary key
value from the QuickCall form, and then have the Daily Dispatch Log form
close the QuickCall form. Then the Daily Dispatch Log form should requery
itself (Me.Requery) and then move to that new record:


Private Sub CmdQuickCall_Click()
Dim PrimKey as Variant
On Error GoTo Err_CmdQuickCall_Click

Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.OpenForm "QuickCall", , , , , acDialog
PrimKey =
Forms("QuickCall").Controls("NameOfControlBoundToPrimaryKeyField").Value
Me.Requery
With Me.RecordsetClone
.MoveFirst
' this code step is used if the primary key is a numeric field
.FindFirst "NameOfPrimaryKeyField = " & PrimKey
' this code step is used if the primary key is a text field
' .FindFirst "NameOfPrimaryKeyField = '" & PrimKey & "'"

' this code step is used if the primary key is a date field
' .FindFirst "NameOfPrimaryKeyField = #" & PrimKey & "#"
If .NoMatch = True Then
MsgBox "cannot find the newly entered record"
Else
Me.Bookmark = .Bookmark
End If
End With

Exit_CmdQuickCall_Click:
Exit Sub

Err_CmdQuickCall_Click:
MsgBox Err.Description
Resume Exit_CmdQuickCall_Click

End Sub


Then the close event procedure in QuickCall would be changed to this:

Private Sub CmdCloseForm_Click()
On Error GoTo Err_CmdCloseForm_Click
Me.Visible = False

Exit_CmdCloseForm_Click:
Exit Sub

Err_CmdCloseForm_Click:
MsgBox Err.Description
Resume Exit_CmdCloseForm_Click

End Sub


Also, this procedure seems to have a redundant step:
Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "QuickCall", , , , , acDialog
DoCmd.GoToRecord , , acNewRec
End Sub

It should be changed to this:
Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
End Sub


--

Ken Snell
<MS ACCESS MVP>


Jennifer P said:
These are the codes that I have. When I insert the Me.Requery I get an
error
message.

Private Sub CmdQuickCall_Click()
On Error GoTo Err_CmdQuickCall_Click

Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.OpenForm "QuickCall", , , , , acDialog
Me.Requery


Exit_CmdQuickCall_Click:
Exit Sub

Err_CmdQuickCall_Click:
MsgBox Err.Description
Resume Exit_CmdQuickCall_Click

End Sub
Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "QuickCall", , , , , acDialog
DoCmd.GoToRecord , , acNewRec
End Sub

Private Sub OnScene_Click()
Me![On Scene] = Now()
End Sub
Private Sub CmdCloseForm_Click()
On Error GoTo Err_CmdCloseForm_Click


DoCmd.Close


Exit_CmdCloseForm_Click:
Exit Sub

Err_CmdCloseForm_Click:
MsgBox Err.Description
Resume Exit_CmdCloseForm_Click

End Sub
Private Sub CmdRefresh_Click()
On Error GoTo Err_CmdRefresh_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70

Exit_CmdRefresh_Click:
Exit Sub

Err_CmdRefresh_Click:
MsgBox Err.Description
Resume Exit_CmdRefresh_Click

End Sub


Ken Snell said:
What is the code that runs when you click the "quick call button"? What
is
the code that runs in the popup form's Close event and in the "done
entering
data" button on the popup form?

--

Ken Snell
<MS ACCESS MVP>

The form that is open is my Daily dispatch Log. It is used to track
all
calls. However if i am in the middle of a call I want to press the
quick
call button and fill in 5 fields and then close the form. The pop up
form
opens to the next availble record in the Daily Dispatch Log. The
problem
is
when I close the pop up form the Daily Dispatch log goes to record 1
and
does
not show that I have added a record. I need it to requery the Daily
Dispatch
Log so I can see the call I added with the Quick Call form. Now if I
close
the Daily Dispatch Log and reopen it, it shows the record I added.

Jen

:

Let me try asking my question in a different way.

In the form that is open all the time, you do something to cause the
popup
form to be opened. Click a button? Post the code that runs in order
to
cause
the popup form to open.

--

Ken Snell
<MS ACCESS MVP>


Okay I understand that however I have the main form open all the
time
it
never closes. The pop form's information is not journaling to the
main
form
unless I close the main form then I can see it when I reopen it.

:

As I indicated in my first reply, this can be done by adding a
requery
step
to the code that is opening the form. Can you post the code that
is
run
when
you click the button to open the popup form?

--

Ken Snell
<MS ACCESS MVP>

message
Okay my pop up is working but the main form that the information
goes
to
is
not updating with the information from the pop up unless I close
it
and
open
it

:

How are you opening the popup form now?

--

Ken Snell
<MS ACCESS MVP>

message
Okay forgive me I am not that advance with Access YET...
I am not sure what "dialog mode" refers to

:

In the code that opens the popup form, after the line that
opens
the
form
(in dialog mode, right?), put a requery step for your
current
form.

Something like this:
DoCmd.OpenForm "popup form", , , , , acDialog
Me.Requery

--

Ken Snell
<MS ACCESS MVP>

message
I have a form call Daily Dispatch Log its table is also
Daily
Dispatch
Log.
I have a pop up form "Quick Call" that opens to a new
record
if
I
am
in
the
Daily Dispatch Log and allows me to put another record in
with.
(Officer,Call
Type, Location, License, State, On Scene). I created the
pop
up
form
so
if I
was in a call I could quickly add another record with out
having
to
leave
the
screen I was in. I need help in setting this pop up form
to
requery
the
information on the Daily Dispatch Log so I am not having
to
close
it
out
to
see it on the main form "Daily Dispatch Log"

Thanks in advance Jen
 

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

Top