Update or Refresh Form

L

Lloyd

I have created a command button and written a series of If
ISNull statements to update address data from one table to
another. (The information is often, but not always the
same.) A sample is shown below.

When I click the button, the data seems to be updated, but
does not show up on the current form until I close out of
the record and reopen it. Can someone suggest the
function I need to use to get the form to display the new
data when the command button has been used?

Thanks, Lloyd

If IsNull(Forms![frmGrantSumDE].[tblGrantSum.City]) Then
[tblGrantSum.City] = [Forms]![frmGrantSumDE].
[tblGrantee.City]
End If
If IsNull(Forms![frmGrantSumDE].[tblGrantSum.Zip]) Then
[tblGrantSum.Zip] = [Forms]![frmGrantSumDE].
[tblGrantee.Zip]
End If
DoCmd.Save
 
M

MacDermott

Ah! The oh-so-common mistake of thinking that DoCmd.Save will save data!
It actually saves design changes.
Try DoCmd.SaveRecord
 
L

Lloyd

I tried docmd.saverecord and got an error message that it
was not supported for this object (using Access97). I
then tried the SaveRecord under docmd.MenuItem. I am
confident that I am getting the data saved, it simply
isn't displaying on my form. I can simply minimize and
restore the form and the data is displayed.

Any additional thoughts?

Thanks, Lloyd
-----Original Message-----
Ah! The oh-so-common mistake of thinking that DoCmd.Save will save data!
It actually saves design changes.
Try DoCmd.SaveRecord


I have created a command button and written a series of If
ISNull statements to update address data from one table to
another. (The information is often, but not always the
same.) A sample is shown below.

When I click the button, the data seems to be updated, but
does not show up on the current form until I close out of
the record and reopen it. Can someone suggest the
function I need to use to get the form to display the new
data when the command button has been used?

Thanks, Lloyd

If IsNull(Forms![frmGrantSumDE].[tblGrantSum.City]) Then
[tblGrantSum.City] = [Forms]![frmGrantSumDE].
[tblGrantee.City]
End If
If IsNull(Forms![frmGrantSumDE].[tblGrantSum.Zip]) Then
[tblGrantSum.Zip] = [Forms]![frmGrantSumDE].
[tblGrantee.Zip]
End If
DoCmd.Save


.
 
M

MacDermott

Perhaps Me.Refresh after you save the data?

- Turtle

Lloyd said:
I tried docmd.saverecord and got an error message that it
was not supported for this object (using Access97). I
then tried the SaveRecord under docmd.MenuItem. I am
confident that I am getting the data saved, it simply
isn't displaying on my form. I can simply minimize and
restore the form and the data is displayed.

Any additional thoughts?

Thanks, Lloyd
-----Original Message-----
Ah! The oh-so-common mistake of thinking that DoCmd.Save will save data!
It actually saves design changes.
Try DoCmd.SaveRecord


I have created a command button and written a series of If
ISNull statements to update address data from one table to
another. (The information is often, but not always the
same.) A sample is shown below.

When I click the button, the data seems to be updated, but
does not show up on the current form until I close out of
the record and reopen it. Can someone suggest the
function I need to use to get the form to display the new
data when the command button has been used?

Thanks, Lloyd

If IsNull(Forms![frmGrantSumDE].[tblGrantSum.City]) Then
[tblGrantSum.City] = [Forms]![frmGrantSumDE].
[tblGrantee.City]
End If
If IsNull(Forms![frmGrantSumDE].[tblGrantSum.Zip]) Then
[tblGrantSum.Zip] = [Forms]![frmGrantSumDE].
[tblGrantee.Zip]
End If
DoCmd.Save


.
 
K

kevin c.

i'm having a similar problem as well. i'm using a form
(form A) to select certain groups of records in another
form (form B) based on a grouping mechanism i have
created. sorry if that doesn't make sense right now.

once the 'criteria' has been set in form A, it creates an
SQL statement and sets it to the recordsource of form B.

i have tried using every combination
of .requery, .refresh, and .update i can think of to
force form B to reflect the new recordset... to no
avail.

the only way form B will reflect the new records is if i
either close it and reopen it or if i simply view the SQL
statement in design mode, exit out of it, and the click
the form.

somebody... please tell me what's going on... i'm at my
wits end with this. thanks.
-----Original Message-----
Perhaps Me.Refresh after you save the data?

- Turtle

I tried docmd.saverecord and got an error message that it
was not supported for this object (using Access97). I
then tried the SaveRecord under docmd.MenuItem. I am
confident that I am getting the data saved, it simply
isn't displaying on my form. I can simply minimize and
restore the form and the data is displayed.

Any additional thoughts?

Thanks, Lloyd
-----Original Message-----
Ah! The oh-so-common mistake of thinking that
DoCmd.Save
will save data!
It actually saves design changes.
Try DoCmd.SaveRecord


I have created a command button and written a
series of
If
ISNull statements to update address data from one
table
to
another. (The information is often, but not always the
same.) A sample is shown below.

When I click the button, the data seems to be
updated,
but
does not show up on the current form until I close
out
of
the record and reopen it. Can someone suggest the
function I need to use to get the form to display
the
new
data when the command button has been used?

Thanks, Lloyd

If IsNull(Forms![frmGrantSumDE].[tblGrantSum.City]) Then
[tblGrantSum.City] = [Forms]![frmGrantSumDE].
[tblGrantee.City]
End If
If IsNull(Forms![frmGrantSumDE].
[tblGrantSum.Zip])
Then
[tblGrantSum.Zip] = [Forms]![frmGrantSumDE].
[tblGrantee.Zip]
End If
DoCmd.Save


.


.
 
M

MacDermott

You haven't said what is in front of the dot in all these things you've
tried.
I'd suggest Forms!FormB.Requery

HTH
- Turtle

kevin c. said:
i'm having a similar problem as well. i'm using a form
(form A) to select certain groups of records in another
form (form B) based on a grouping mechanism i have
created. sorry if that doesn't make sense right now.

once the 'criteria' has been set in form A, it creates an
SQL statement and sets it to the recordsource of form B.

i have tried using every combination
of .requery, .refresh, and .update i can think of to
force form B to reflect the new recordset... to no
avail.

the only way form B will reflect the new records is if i
either close it and reopen it or if i simply view the SQL
statement in design mode, exit out of it, and the click
the form.

somebody... please tell me what's going on... i'm at my
wits end with this. thanks.
-----Original Message-----
Perhaps Me.Refresh after you save the data?

- Turtle

I tried docmd.saverecord and got an error message that it
was not supported for this object (using Access97). I
then tried the SaveRecord under docmd.MenuItem. I am
confident that I am getting the data saved, it simply
isn't displaying on my form. I can simply minimize and
restore the form and the data is displayed.

Any additional thoughts?

Thanks, Lloyd

-----Original Message-----
Ah! The oh-so-common mistake of thinking that DoCmd.Save
will save data!
It actually saves design changes.
Try DoCmd.SaveRecord


message
I have created a command button and written a series of
If
ISNull statements to update address data from one table
to
another. (The information is often, but not always the
same.) A sample is shown below.

When I click the button, the data seems to be updated,
but
does not show up on the current form until I close out
of
the record and reopen it. Can someone suggest the
function I need to use to get the form to display the
new
data when the command button has been used?

Thanks, Lloyd

If IsNull(Forms![frmGrantSumDE].[tblGrantSum.City]) Then
[tblGrantSum.City] = [Forms]![frmGrantSumDE].
[tblGrantee.City]
End If
If IsNull(Forms![frmGrantSumDE]. [tblGrantSum.Zip])
Then
[tblGrantSum.Zip] = [Forms]![frmGrantSumDE].
[tblGrantee.Zip]
End If
DoCmd.Save


.


.
 
K

kevin c

i have definately tried that.

i've also tried:
Forms!FormB.Refresh
Me.requery
out of desparation, i've also tried .repaint

i've tried requerying form A from form B. i've tried
requerying Form A with an On Click event. On Activate.
everything after the initial Forms!FormB.Requery was done
out of desparation, as I did not really expect certain
things to make a difference.

got any other ideas?

thanks. :)

Kevin

-----Original Message-----
You haven't said what is in front of the dot in all these things you've
tried.
I'd suggest Forms!FormB.Requery

HTH
- Turtle

i'm having a similar problem as well. i'm using a form
(form A) to select certain groups of records in another
form (form B) based on a grouping mechanism i have
created. sorry if that doesn't make sense right now.

once the 'criteria' has been set in form A, it creates an
SQL statement and sets it to the recordsource of form B.

i have tried using every combination
of .requery, .refresh, and .update i can think of to
force form B to reflect the new recordset... to no
avail.

the only way form B will reflect the new records is if i
either close it and reopen it or if i simply view the SQL
statement in design mode, exit out of it, and the click
the form.

somebody... please tell me what's going on... i'm at my
wits end with this. thanks.
-----Original Message-----
Perhaps Me.Refresh after you save the data?

- Turtle

I tried docmd.saverecord and got an error message
that
it
was not supported for this object (using Access97). I
then tried the SaveRecord under docmd.MenuItem. I am
confident that I am getting the data saved, it simply
isn't displaying on my form. I can simply minimize and
restore the form and the data is displayed.

Any additional thoughts?

Thanks, Lloyd

-----Original Message-----
Ah! The oh-so-common mistake of thinking that DoCmd.Save
will save data!
It actually saves design changes.
Try DoCmd.SaveRecord


message
I have created a command button and written a series of
If
ISNull statements to update address data from one table
to
another. (The information is often, but not
always
the
same.) A sample is shown below.

When I click the button, the data seems to be updated,
but
does not show up on the current form until I
close
out
of
the record and reopen it. Can someone suggest the
function I need to use to get the form to display the
new
data when the command button has been used?

Thanks, Lloyd

If IsNull(Forms![frmGrantSumDE].
[tblGrantSum.City])
Then
[tblGrantSum.City] = [Forms]![frmGrantSumDE].
[tblGrantee.City]
End If
If IsNull(Forms![frmGrantSumDE]. [tblGrantSum.Zip])
Then
[tblGrantSum.Zip] = [Forms]![frmGrantSumDE].
[tblGrantee.Zip]
End If
DoCmd.Save


.



.


.
 
M

MacDermott

Perhaps you could post the code which re-creates the recordset.

- Turtle

kevin c said:
i have definately tried that.

i've also tried:
Forms!FormB.Refresh
Me.requery
out of desparation, i've also tried .repaint

i've tried requerying form A from form B. i've tried
requerying Form A with an On Click event. On Activate.
everything after the initial Forms!FormB.Requery was done
out of desparation, as I did not really expect certain
things to make a difference.

got any other ideas?

thanks. :)

Kevin

-----Original Message-----
You haven't said what is in front of the dot in all these things you've
tried.
I'd suggest Forms!FormB.Requery

HTH
- Turtle

i'm having a similar problem as well. i'm using a form
(form A) to select certain groups of records in another
form (form B) based on a grouping mechanism i have
created. sorry if that doesn't make sense right now.

once the 'criteria' has been set in form A, it creates an
SQL statement and sets it to the recordsource of form B.

i have tried using every combination
of .requery, .refresh, and .update i can think of to
force form B to reflect the new recordset... to no
avail.

the only way form B will reflect the new records is if i
either close it and reopen it or if i simply view the SQL
statement in design mode, exit out of it, and the click
the form.

somebody... please tell me what's going on... i'm at my
wits end with this. thanks.

-----Original Message-----
Perhaps Me.Refresh after you save the data?

- Turtle

message
I tried docmd.saverecord and got an error message that
it
was not supported for this object (using Access97). I
then tried the SaveRecord under docmd.MenuItem. I am
confident that I am getting the data saved, it simply
isn't displaying on my form. I can simply minimize and
restore the form and the data is displayed.

Any additional thoughts?

Thanks, Lloyd

-----Original Message-----
Ah! The oh-so-common mistake of thinking that
DoCmd.Save
will save data!
It actually saves design changes.
Try DoCmd.SaveRecord


message
I have created a command button and written a
series of
If
ISNull statements to update address data from one
table
to
another. (The information is often, but not always
the
same.) A sample is shown below.

When I click the button, the data seems to be
updated,
but
does not show up on the current form until I close
out
of
the record and reopen it. Can someone suggest the
function I need to use to get the form to display
the
new
data when the command button has been used?

Thanks, Lloyd

If IsNull(Forms![frmGrantSumDE]. [tblGrantSum.City])
Then
[tblGrantSum.City] = [Forms]![frmGrantSumDE].
[tblGrantee.City]
End If
If IsNull(Forms![frmGrantSumDE].
[tblGrantSum.Zip])
Then
[tblGrantSum.Zip] = [Forms]![frmGrantSumDE].
[tblGrantee.Zip]
End If
DoCmd.Save


.



.


.
 
K

kevin c

below i've included the code for you to see. believe it
or not, it is formatted neatly. Just paste it into word
pad and it should look fine. i've included some comment
lines just to give you a rough idea of what's going on.
thanks.

Kevin

'---Begin Code---'

'The following code occurs in the On Current event
property of a form called 'group'
'The intially checks the action field of each record. If
the action field is true, then variable 'selected' is
incremented.
'The next section of code checks the final value of
variable 'selected'. A new variable YorN is assigned a
string value based on the value of 'selected'
'The string stored in YorN is the last part of the SQL
statement refered to in qryTest2.SQL.

Dim number, selected, qty As Integer
Dim phrase1, phrase2, YorN As String
Dim dbs As Database
Dim rst1 As DAO.Recordset
Dim qryTest1, qryTest2 As QueryDef

Set dbs = CurrentDb
Set rst1 = Forms!home!project!group.Form.RecordsetClone

selected = 0

If rst1.RecordCount <> 0 Then
rst1.MoveLast
Do Until rst1.BOF
If rst1!action = True Then
selected = selected + 1
End If
rst1.MovePrevious
Loop
End If

If selected = 0 Then
YorN = ") ORDER BY estimateLabor.groupLineItem"
Else
YorN = " And ((group.action) = Yes)) ORDER BY
estimateLabor.groupLineItem"
End If

Set qryTest2 = dbs.QueryDefs("laborQuery")

'The following SQL statement DOES execute without error.

qryTest2.SQL = "SELECT estimateLabor.recordID,
estimateLabor.recordType, estimateLabor.projectRecordID,"
& _
"estimateLabor.descriptionOfLabor,
estimateLabor.unitCost, estimateLabor.extendedPrice,
estimateLabor.quantity," & _
"estimateLabor.lineItem, estimateLabor.group,
estimateLabor.extendedTime, estimateLabor.unitTime," & _
"estimateLabor.groupLineItem,
estimateLabor.changeOrderNumber, estimateLabor.memo,
estimateLabor.action As laborAction," & _
"estimateLabor.pendingAction, project.actionAll,
estimateLabor.invoiceNumber, group.action" & _
" FROM [group] Right JOIN (estimateLabor INNER
JOIN project" & _
" ON
estimateLabor.projectRecordID=project.projectRecordID)" &
_
" ON group.recordID=estimateLabor.group" & _
" WHERE (((estimateLabor.recordType) = Forms!home!
project!recordType)" & _
" And((estimateLabor.projectRecordID)=[Forms]!
[home]![project]![projectNumber])" & _
" And ((estimateLabor.changeOrderNumber) = Forms!
home!project!corNumber)" & _
" And ((estimateLabor.invoiceNumber) = Forms!home!
project!invoiceID)" & YorN & ";"
rst1.close

'The estimateLabor form refered to in the following
statement does NOT requery properly.
'When I leave the 'group' form after all of the above
code executes, and view the following form, the viewable
recordest is the same as before the code executed.
'If I open the properties window, click on the '...'
button to view the record source, then close it, and then
click on the form, the recordset immediately updates.

Forms!home!project!estimate!estimateLabor.Requery

'---End Code---
-----Original Message-----
Perhaps you could post the code which re-creates the recordset.

- Turtle

i have definately tried that.

i've also tried:
Forms!FormB.Refresh
Me.requery
out of desparation, i've also tried .repaint

i've tried requerying form A from form B. i've tried
requerying Form A with an On Click event. On Activate.
everything after the initial Forms!FormB.Requery was done
out of desparation, as I did not really expect certain
things to make a difference.

got any other ideas?

thanks. :)

Kevin

-----Original Message-----
You haven't said what is in front of the dot in all these things you've
tried.
I'd suggest Forms!FormB.Requery

HTH
- Turtle

i'm having a similar problem as well. i'm using a form
(form A) to select certain groups of records in another
form (form B) based on a grouping mechanism i have
created. sorry if that doesn't make sense right now.

once the 'criteria' has been set in form A, it
creates
an
SQL statement and sets it to the recordsource of
form
B.
i have tried using every combination
of .requery, .refresh, and .update i can think of to
force form B to reflect the new recordset... to no
avail.

the only way form B will reflect the new records is
if
i
either close it and reopen it or if i simply view
the
SQL
statement in design mode, exit out of it, and the click
the form.

somebody... please tell me what's going on... i'm at my
wits end with this. thanks.

-----Original Message-----
Perhaps Me.Refresh after you save the data?

- Turtle

message
I tried docmd.saverecord and got an error message that
it
was not supported for this object (using Access97). I
then tried the SaveRecord under docmd.MenuItem.
I
am
confident that I am getting the data saved, it simply
isn't displaying on my form. I can simply
minimize
and
restore the form and the data is displayed.

Any additional thoughts?

Thanks, Lloyd

-----Original Message-----
Ah! The oh-so-common mistake of thinking that
DoCmd.Save
will save data!
It actually saves design changes.
Try DoCmd.SaveRecord


message
I have created a command button and written a
series of
If
ISNull statements to update address data from one
table
to
another. (The information is often, but not always
the
same.) A sample is shown below.

When I click the button, the data seems to be
updated,
but
does not show up on the current form until I close
out
of
the record and reopen it. Can someone suggest the
function I need to use to get the form to display
the
new
data when the command button has been used?

Thanks, Lloyd

If IsNull(Forms![frmGrantSumDE]. [tblGrantSum.City])
Then
[tblGrantSum.City] = [Forms]! [frmGrantSumDE].
[tblGrantee.City]
End If
If IsNull(Forms![frmGrantSumDE].
[tblGrantSum.Zip])
Then
[tblGrantSum.Zip] = [Forms]! [frmGrantSumDE].
[tblGrantee.Zip]
End If
DoCmd.Save


.



.



.


.
 
M

MacDermott

I'm a bit perplexed by your syntax here:
Forms!home!project!group.Form.RecordsetClone
It looks as if you have a form named home, but what are the objects named
"project" and "group"?


kevin c said:
below i've included the code for you to see. believe it
or not, it is formatted neatly. Just paste it into word
pad and it should look fine. i've included some comment
lines just to give you a rough idea of what's going on.
thanks.

Kevin

'---Begin Code---'

'The following code occurs in the On Current event
property of a form called 'group'
'The intially checks the action field of each record. If
the action field is true, then variable 'selected' is
incremented.
'The next section of code checks the final value of
variable 'selected'. A new variable YorN is assigned a
string value based on the value of 'selected'
'The string stored in YorN is the last part of the SQL
statement refered to in qryTest2.SQL.

Dim number, selected, qty As Integer
Dim phrase1, phrase2, YorN As String
Dim dbs As Database
Dim rst1 As DAO.Recordset
Dim qryTest1, qryTest2 As QueryDef

Set dbs = CurrentDb
Set rst1 = Forms!home!project!group.Form.RecordsetClone

selected = 0

If rst1.RecordCount <> 0 Then
rst1.MoveLast
Do Until rst1.BOF
If rst1!action = True Then
selected = selected + 1
End If
rst1.MovePrevious
Loop
End If

If selected = 0 Then
YorN = ") ORDER BY estimateLabor.groupLineItem"
Else
YorN = " And ((group.action) = Yes)) ORDER BY
estimateLabor.groupLineItem"
End If

Set qryTest2 = dbs.QueryDefs("laborQuery")

'The following SQL statement DOES execute without error.

qryTest2.SQL = "SELECT estimateLabor.recordID,
estimateLabor.recordType, estimateLabor.projectRecordID,"
& _
"estimateLabor.descriptionOfLabor,
estimateLabor.unitCost, estimateLabor.extendedPrice,
estimateLabor.quantity," & _
"estimateLabor.lineItem, estimateLabor.group,
estimateLabor.extendedTime, estimateLabor.unitTime," & _
"estimateLabor.groupLineItem,
estimateLabor.changeOrderNumber, estimateLabor.memo,
estimateLabor.action As laborAction," & _
"estimateLabor.pendingAction, project.actionAll,
estimateLabor.invoiceNumber, group.action" & _
" FROM [group] Right JOIN (estimateLabor INNER
JOIN project" & _
" ON
estimateLabor.projectRecordID=project.projectRecordID)" &
_
" ON group.recordID=estimateLabor.group" & _
" WHERE (((estimateLabor.recordType) = Forms!home!
project!recordType)" & _
" And((estimateLabor.projectRecordID)=[Forms]!
[home]![project]![projectNumber])" & _
" And ((estimateLabor.changeOrderNumber) = Forms!
home!project!corNumber)" & _
" And ((estimateLabor.invoiceNumber) = Forms!home!
project!invoiceID)" & YorN & ";"
rst1.close

'The estimateLabor form refered to in the following
statement does NOT requery properly.
'When I leave the 'group' form after all of the above
code executes, and view the following form, the viewable
recordest is the same as before the code executed.
'If I open the properties window, click on the '...'
button to view the record source, then close it, and then
click on the form, the recordset immediately updates.

Forms!home!project!estimate!estimateLabor.Requery

'---End Code---
-----Original Message-----
Perhaps you could post the code which re-creates the recordset.

- Turtle

i have definately tried that.

i've also tried:
Forms!FormB.Refresh
Me.requery
out of desparation, i've also tried .repaint

i've tried requerying form A from form B. i've tried
requerying Form A with an On Click event. On Activate.
everything after the initial Forms!FormB.Requery was done
out of desparation, as I did not really expect certain
things to make a difference.

got any other ideas?

thanks. :)

Kevin


-----Original Message-----
You haven't said what is in front of the dot in all
these things you've
tried.
I'd suggest Forms!FormB.Requery

HTH
- Turtle

in message
i'm having a similar problem as well. i'm using a form
(form A) to select certain groups of records in another
form (form B) based on a grouping mechanism i have
created. sorry if that doesn't make sense right now.

once the 'criteria' has been set in form A, it creates
an
SQL statement and sets it to the recordsource of form
B.

i have tried using every combination
of .requery, .refresh, and .update i can think of to
force form B to reflect the new recordset... to no
avail.

the only way form B will reflect the new records is if
i
either close it and reopen it or if i simply view the
SQL
statement in design mode, exit out of it, and the click
the form.

somebody... please tell me what's going on... i'm at my
wits end with this. thanks.

-----Original Message-----
Perhaps Me.Refresh after you save the data?

- Turtle

message
I tried docmd.saverecord and got an error message
that
it
was not supported for this object (using
Access97). I
then tried the SaveRecord under docmd.MenuItem. I
am
confident that I am getting the data saved, it
simply
isn't displaying on my form. I can simply minimize
and
restore the form and the data is displayed.

Any additional thoughts?

Thanks, Lloyd

-----Original Message-----
Ah! The oh-so-common mistake of thinking that
DoCmd.Save
will save data!
It actually saves design changes.
Try DoCmd.SaveRecord


"Lloyd" <[email protected]>
wrote in
message
I have created a command button and written a
series of
If
ISNull statements to update address data from one
table
to
another. (The information is often, but not
always
the
same.) A sample is shown below.

When I click the button, the data seems to be
updated,
but
does not show up on the current form until I
close
out
of
the record and reopen it. Can someone suggest
the
function I need to use to get the form to display
the
new
data when the command button has been used?

Thanks, Lloyd

If IsNull(Forms![frmGrantSumDE].
[tblGrantSum.City])
Then
[tblGrantSum.City] = [Forms]! [frmGrantSumDE].
[tblGrantee.City]
End If
If IsNull(Forms![frmGrantSumDE].
[tblGrantSum.Zip])
Then
[tblGrantSum.Zip] = [Forms]! [frmGrantSumDE].
[tblGrantee.Zip]
End If
DoCmd.Save


.



.



.


.
 
K

kevin c

yeah i can see how this can be confusing. :)

home is the 'main' form. project is a subform to home
and group is a subform to project. hope this helps...

Kevin

-----Original Message-----
I'm a bit perplexed by your syntax here:
Forms!home!project!group.Form.RecordsetClone
It looks as if you have a form named home, but what are the objects named
"project" and "group"?


below i've included the code for you to see. believe it
or not, it is formatted neatly. Just paste it into word
pad and it should look fine. i've included some comment
lines just to give you a rough idea of what's going on.
thanks.

Kevin

'---Begin Code---'

'The following code occurs in the On Current event
property of a form called 'group'
'The intially checks the action field of each record. If
the action field is true, then variable 'selected' is
incremented.
'The next section of code checks the final value of
variable 'selected'. A new variable YorN is assigned a
string value based on the value of 'selected'
'The string stored in YorN is the last part of the SQL
statement refered to in qryTest2.SQL.

Dim number, selected, qty As Integer
Dim phrase1, phrase2, YorN As String
Dim dbs As Database
Dim rst1 As DAO.Recordset
Dim qryTest1, qryTest2 As QueryDef

Set dbs = CurrentDb
Set rst1 = Forms!home!project!group.Form.RecordsetClone

selected = 0

If rst1.RecordCount <> 0 Then
rst1.MoveLast
Do Until rst1.BOF
If rst1!action = True Then
selected = selected + 1
End If
rst1.MovePrevious
Loop
End If

If selected = 0 Then
YorN = ") ORDER BY estimateLabor.groupLineItem"
Else
YorN = " And ((group.action) = Yes)) ORDER BY
estimateLabor.groupLineItem"
End If

Set qryTest2 = dbs.QueryDefs("laborQuery")

'The following SQL statement DOES execute without error.

qryTest2.SQL = "SELECT estimateLabor.recordID,
estimateLabor.recordType, estimateLabor.projectRecordID,"
& _
"estimateLabor.descriptionOfLabor,
estimateLabor.unitCost, estimateLabor.extendedPrice,
estimateLabor.quantity," & _
"estimateLabor.lineItem, estimateLabor.group,
estimateLabor.extendedTime, estimateLabor.unitTime," & _
"estimateLabor.groupLineItem,
estimateLabor.changeOrderNumber, estimateLabor.memo,
estimateLabor.action As laborAction," & _
"estimateLabor.pendingAction, project.actionAll,
estimateLabor.invoiceNumber, group.action" & _
" FROM [group] Right JOIN (estimateLabor INNER
JOIN project" & _
" ON
estimateLabor.projectRecordID=project.projectRecordID)" &
_
" ON group.recordID=estimateLabor.group" & _
" WHERE (((estimateLabor.recordType) = Forms!home!
project!recordType)" & _
" And((estimateLabor.projectRecordID)=[Forms]!
[home]![project]![projectNumber])" & _
" And ((estimateLabor.changeOrderNumber) = Forms!
home!project!corNumber)" & _
" And ((estimateLabor.invoiceNumber) = Forms!home!
project!invoiceID)" & YorN & ";"
rst1.close

'The estimateLabor form refered to in the following
statement does NOT requery properly.
'When I leave the 'group' form after all of the above
code executes, and view the following form, the viewable
recordest is the same as before the code executed.
'If I open the properties window, click on the '...'
button to view the record source, then close it, and then
click on the form, the recordset immediately updates.

Forms!home!project!estimate!estimateLabor.Requery

'---End Code---
-----Original Message-----
Perhaps you could post the code which re-creates the recordset.

- Turtle

"kevin c" <[email protected]> wrote
in
message
i have definately tried that.

i've also tried:
Forms!FormB.Refresh
Me.requery
out of desparation, i've also tried .repaint

i've tried requerying form A from form B. i've tried
requerying Form A with an On Click event. On Activate.
everything after the initial Forms!FormB.Requery was done
out of desparation, as I did not really expect certain
things to make a difference.

got any other ideas?

thanks. :)

Kevin


-----Original Message-----
You haven't said what is in front of the dot in all
these things you've
tried.
I'd suggest Forms!FormB.Requery

HTH
- Turtle

in message
i'm having a similar problem as well. i'm using
a
form
(form A) to select certain groups of records in another
form (form B) based on a grouping mechanism i have
created. sorry if that doesn't make sense right now.

once the 'criteria' has been set in form A, it creates
an
SQL statement and sets it to the recordsource of form
B.

i have tried using every combination
of .requery, .refresh, and .update i can think of to
force form B to reflect the new recordset... to no
avail.

the only way form B will reflect the new records
is
if
i
either close it and reopen it or if i simply view the
SQL
statement in design mode, exit out of it, and the click
the form.

somebody... please tell me what's going on... i'm at my
wits end with this. thanks.

-----Original Message-----
Perhaps Me.Refresh after you save the data?

- Turtle

message
I tried docmd.saverecord and got an error message
that
it
was not supported for this object (using
Access97). I
then tried the SaveRecord under
docmd.MenuItem.
I
am
confident that I am getting the data saved, it
simply
isn't displaying on my form. I can simply minimize
and
restore the form and the data is displayed.

Any additional thoughts?

Thanks, Lloyd

-----Original Message-----
Ah! The oh-so-common mistake of thinking that
DoCmd.Save
will save data!
It actually saves design changes.
Try DoCmd.SaveRecord


"Lloyd" <[email protected]>
wrote in
message
[email protected]...
I have created a command button and written a
series of
If
ISNull statements to update address data
from
one
table
to
another. (The information is often, but not
always
the
same.) A sample is shown below.

When I click the button, the data seems to be
updated,
but
does not show up on the current form until I
close
out
of
the record and reopen it. Can someone suggest
the
function I need to use to get the form to display
the
new
data when the command button has been used?

Thanks, Lloyd

If IsNull(Forms![frmGrantSumDE].
[tblGrantSum.City])
Then
[tblGrantSum.City] = [Forms]! [frmGrantSumDE].
[tblGrantee.City]
End If
If IsNull(Forms![frmGrantSumDE].
[tblGrantSum.Zip])
Then
[tblGrantSum.Zip] = [Forms]! [frmGrantSumDE].
[tblGrantee.Zip]
End If
DoCmd.Save


.



.



.



.


.
 
M

MacDermott

While apparently in newer versions of Access, this syntax can sometimes
work, it's always better to try this:
Forms!home!project.form![group].form.recordsetclone
Here's the thinking:
Strictly speaking, Forms!home!project refers to a control (the subform
control) on the form home, named project. The subform control does not
contain further controls; it contains a form. That form in turn contains
other controls, including the subform control named group.
Also note the square brackets around [group] - square brackets around
names are never, AFAIK, a problem, and are a good idea any time the name is
a word which may have other meanings to Access.

Here's another thought, which might help:
Instead of your line
Forms!home!project!estimate!estimateLabor.Requery
try this
Forms!home!project!estimate!estimateLabor.RecordSource="laborQuery"

HTH
- Turtle


kevin c said:
yeah i can see how this can be confusing. :)

home is the 'main' form. project is a subform to home
and group is a subform to project. hope this helps...

Kevin

-----Original Message-----
I'm a bit perplexed by your syntax here:
Forms!home!project!group.Form.RecordsetClone
It looks as if you have a form named home, but what are the objects named
"project" and "group"?


below i've included the code for you to see. believe it
or not, it is formatted neatly. Just paste it into word
pad and it should look fine. i've included some comment
lines just to give you a rough idea of what's going on.
thanks.

Kevin

'---Begin Code---'

'The following code occurs in the On Current event
property of a form called 'group'
'The intially checks the action field of each record. If
the action field is true, then variable 'selected' is
incremented.
'The next section of code checks the final value of
variable 'selected'. A new variable YorN is assigned a
string value based on the value of 'selected'
'The string stored in YorN is the last part of the SQL
statement refered to in qryTest2.SQL.

Dim number, selected, qty As Integer
Dim phrase1, phrase2, YorN As String
Dim dbs As Database
Dim rst1 As DAO.Recordset
Dim qryTest1, qryTest2 As QueryDef

Set dbs = CurrentDb
Set rst1 = Forms!home!project!group.Form.RecordsetClone

selected = 0

If rst1.RecordCount <> 0 Then
rst1.MoveLast
Do Until rst1.BOF
If rst1!action = True Then
selected = selected + 1
End If
rst1.MovePrevious
Loop
End If

If selected = 0 Then
YorN = ") ORDER BY estimateLabor.groupLineItem"
Else
YorN = " And ((group.action) = Yes)) ORDER BY
estimateLabor.groupLineItem"
End If

Set qryTest2 = dbs.QueryDefs("laborQuery")

'The following SQL statement DOES execute without error.

qryTest2.SQL = "SELECT estimateLabor.recordID,
estimateLabor.recordType, estimateLabor.projectRecordID,"
& _
"estimateLabor.descriptionOfLabor,
estimateLabor.unitCost, estimateLabor.extendedPrice,
estimateLabor.quantity," & _
"estimateLabor.lineItem, estimateLabor.group,
estimateLabor.extendedTime, estimateLabor.unitTime," & _
"estimateLabor.groupLineItem,
estimateLabor.changeOrderNumber, estimateLabor.memo,
estimateLabor.action As laborAction," & _
"estimateLabor.pendingAction, project.actionAll,
estimateLabor.invoiceNumber, group.action" & _
" FROM [group] Right JOIN (estimateLabor INNER
JOIN project" & _
" ON
estimateLabor.projectRecordID=project.projectRecordID)" &
_
" ON group.recordID=estimateLabor.group" & _
" WHERE (((estimateLabor.recordType) = Forms!home!
project!recordType)" & _
" And((estimateLabor.projectRecordID)=[Forms]!
[home]![project]![projectNumber])" & _
" And ((estimateLabor.changeOrderNumber) = Forms!
home!project!corNumber)" & _
" And ((estimateLabor.invoiceNumber) = Forms!home!
project!invoiceID)" & YorN & ";"
rst1.close

'The estimateLabor form refered to in the following
statement does NOT requery properly.
'When I leave the 'group' form after all of the above
code executes, and view the following form, the viewable
recordest is the same as before the code executed.
'If I open the properties window, click on the '...'
button to view the record source, then close it, and then
click on the form, the recordset immediately updates.

Forms!home!project!estimate!estimateLabor.Requery

'---End Code---

-----Original Message-----
Perhaps you could post the code which re-creates the
recordset.

- Turtle

message
i have definately tried that.

i've also tried:
Forms!FormB.Refresh
Me.requery
out of desparation, i've also tried .repaint

i've tried requerying form A from form B. i've tried
requerying Form A with an On Click event. On Activate.
everything after the initial Forms!FormB.Requery was
done
out of desparation, as I did not really expect certain
things to make a difference.

got any other ideas?

thanks. :)

Kevin


-----Original Message-----
You haven't said what is in front of the dot in all
these things you've
tried.
I'd suggest Forms!FormB.Requery

HTH
- Turtle

in message
i'm having a similar problem as well. i'm using a
form
(form A) to select certain groups of records in
another
form (form B) based on a grouping mechanism i have
created. sorry if that doesn't make sense right
now.

once the 'criteria' has been set in form A, it
creates
an
SQL statement and sets it to the recordsource of
form
B.

i have tried using every combination
of .requery, .refresh, and .update i can think of to
force form B to reflect the new recordset... to no
avail.

the only way form B will reflect the new records is
if
i
either close it and reopen it or if i simply view
the
SQL
statement in design mode, exit out of it, and the
click
the form.

somebody... please tell me what's going on... i'm
at my
wits end with this. thanks.

-----Original Message-----
Perhaps Me.Refresh after you save the data?

- Turtle

"Lloyd" <[email protected]>
wrote in
message
I tried docmd.saverecord and got an error message
that
it
was not supported for this object (using
Access97). I
then tried the SaveRecord under docmd.MenuItem.
I
am
confident that I am getting the data saved, it
simply
isn't displaying on my form. I can simply
minimize
and
restore the form and the data is displayed.

Any additional thoughts?

Thanks, Lloyd

-----Original Message-----
Ah! The oh-so-common mistake of thinking that
DoCmd.Save
will save data!
It actually saves design changes.
Try DoCmd.SaveRecord


"Lloyd" <[email protected]>
wrote in
message
[email protected]...
I have created a command button and written a
series of
If
ISNull statements to update address data from
one
table
to
another. (The information is often, but not
always
the
same.) A sample is shown below.

When I click the button, the data seems to be
updated,
but
does not show up on the current form until I
close
out
of
the record and reopen it. Can someone suggest
the
function I need to use to get the form to
display
the
new
data when the command button has been used?

Thanks, Lloyd

If IsNull(Forms![frmGrantSumDE].
[tblGrantSum.City])
Then
[tblGrantSum.City] = [Forms]!
[frmGrantSumDE].
[tblGrantee.City]
End If
If IsNull(Forms![frmGrantSumDE].
[tblGrantSum.Zip])
Then
[tblGrantSum.Zip] = [Forms]!
[frmGrantSumDE].
[tblGrantee.Zip]
End If
DoCmd.Save


.



.



.



.


.
 
K

kevin c

thanks for the tip in the first part part of your email.
i understand that and it makes good sense.

i'm having a problem with this syntax though:
Forms!home!project!estimate!
estimateLabor.RecordSource="laborQuery"

when the code runs it produces the 'way too common'
error. 'Object does not support this method or property',
which doesn't makes sense to me. and actually, it's
interesting that you suggest to do that. originally,
before using all the queryTest2.SQL stuff, i simply tried
to set the record source to the SQL statement that i
needed by putting it in quotes. you know how if you use
the query builder on the rowsource property of a combo
box, you create an SQL string that shows up as the row
source as opposed to an actual query name... (if that
makes sense). Anyway, the two methods produce the same
error.

i would expect that you SHOULD be able to do the same for
form record sources (as opposed to row source... the idea
is the same... building a query as some kind of a
source), but apparently not. Maybe it's because the form
is not a control in the same way that a combo box is.

either way, i've had no luck using the .recordsource
command to set the record sources of forms... :-(

willing to keep trying whatever you've got! :)

thanks

Kevin




-----Original Message-----
While apparently in newer versions of Access, this syntax can sometimes
work, it's always better to try this:
Forms!home!project.form![group].form.recordsetclone
Here's the thinking:
Strictly speaking, Forms!home!project refers to a control (the subform
control) on the form home, named project. The subform control does not
contain further controls; it contains a form. That form in turn contains
other controls, including the subform control named group.
Also note the square brackets around [group] - square brackets around
names are never, AFAIK, a problem, and are a good idea any time the name is
a word which may have other meanings to Access.

Here's another thought, which might help:
Instead of your line
Forms!home!project!estimate!estimateLabor.Requery
try this
Forms!home!project!estimate! estimateLabor.RecordSource="laborQuery"

HTH
- Turtle


yeah i can see how this can be confusing. :)

home is the 'main' form. project is a subform to home
and group is a subform to project. hope this helps...

Kevin

-----Original Message-----
I'm a bit perplexed by your syntax here:
Forms!home!project!group.Form.RecordsetClone
It looks as if you have a form named home, but what
are
the objects named
"project" and "group"?


"kevin c" <[email protected]> wrote
in
message
below i've included the code for you to see.
believe
it
or not, it is formatted neatly. Just paste it into word
pad and it should look fine. i've included some comment
lines just to give you a rough idea of what's going on.
thanks.

Kevin

'---Begin Code---'

'The following code occurs in the On Current event
property of a form called 'group'
'The intially checks the action field of each
record.
If
the action field is true, then variable 'selected' is
incremented.
'The next section of code checks the final value of
variable 'selected'. A new variable YorN is assigned a
string value based on the value of 'selected'
'The string stored in YorN is the last part of the SQL
statement refered to in qryTest2.SQL.

Dim number, selected, qty As Integer
Dim phrase1, phrase2, YorN As String
Dim dbs As Database
Dim rst1 As DAO.Recordset
Dim qryTest1, qryTest2 As QueryDef

Set dbs = CurrentDb
Set rst1 = Forms!home!project! group.Form.RecordsetClone

selected = 0

If rst1.RecordCount <> 0 Then
rst1.MoveLast
Do Until rst1.BOF
If rst1!action = True Then
selected = selected + 1
End If
rst1.MovePrevious
Loop
End If

If selected = 0 Then
YorN = ") ORDER BY estimateLabor.groupLineItem"
Else
YorN = " And ((group.action) = Yes)) ORDER BY
estimateLabor.groupLineItem"
End If

Set qryTest2 = dbs.QueryDefs("laborQuery")

'The following SQL statement DOES execute without error.

qryTest2.SQL = "SELECT estimateLabor.recordID,
estimateLabor.recordType, estimateLabor.projectRecordID,"
& _
"estimateLabor.descriptionOfLabor,
estimateLabor.unitCost, estimateLabor.extendedPrice,
estimateLabor.quantity," & _
"estimateLabor.lineItem, estimateLabor.group,
estimateLabor.extendedTime,
estimateLabor.unitTime," &
_
"estimateLabor.groupLineItem,
estimateLabor.changeOrderNumber, estimateLabor.memo,
estimateLabor.action As laborAction," & _
"estimateLabor.pendingAction, project.actionAll,
estimateLabor.invoiceNumber, group.action" & _
" FROM [group] Right JOIN (estimateLabor INNER
JOIN project" & _
" ON
estimateLabor.projectRecordID=project.projectRecordID)" &
_
" ON group.recordID=estimateLabor.group" & _
" WHERE (((estimateLabor.recordType) = Forms! home!
project!recordType)" & _
" And((estimateLabor.projectRecordID)=[Forms]!
[home]![project]![projectNumber])" & _
" And ((estimateLabor.changeOrderNumber) = Forms!
home!project!corNumber)" & _
" And ((estimateLabor.invoiceNumber) = Forms! home!
project!invoiceID)" & YorN & ";"
rst1.close

'The estimateLabor form refered to in the following
statement does NOT requery properly.
'When I leave the 'group' form after all of the above
code executes, and view the following form, the viewable
recordest is the same as before the code executed.
'If I open the properties window, click on the '...'
button to view the record source, then close it, and then
click on the form, the recordset immediately updates.

Forms!home!project!estimate!estimateLabor.Requery

'---End Code---

-----Original Message-----
Perhaps you could post the code which re-creates the
recordset.

- Turtle

"kevin c" <[email protected]>
wrote
in
message
i have definately tried that.

i've also tried:
Forms!FormB.Refresh
Me.requery
out of desparation, i've also tried .repaint

i've tried requerying form A from form B. i've tried
requerying Form A with an On Click event. On Activate.
everything after the initial Forms!FormB.Requery was
done
out of desparation, as I did not really expect certain
things to make a difference.

got any other ideas?

thanks. :)

Kevin


-----Original Message-----
You haven't said what is in front of the dot in all
these things you've
tried.
I'd suggest Forms!FormB.Requery

HTH
- Turtle

in message
i'm having a similar problem as well. i'm
using
a
form
(form A) to select certain groups of records in
another
form (form B) based on a grouping mechanism i have
created. sorry if that doesn't make sense right
now.

once the 'criteria' has been set in form A, it
creates
an
SQL statement and sets it to the recordsource of
form
B.

i have tried using every combination
of .requery, .refresh, and .update i can think of to
force form B to reflect the new recordset...
to
no
avail.

the only way form B will reflect the new
records
is
if
i
either close it and reopen it or if i simply view
the
SQL
statement in design mode, exit out of it, and the
click
the form.

somebody... please tell me what's going on... i'm
at my
wits end with this. thanks.

-----Original Message-----
Perhaps Me.Refresh after you save the data?

- Turtle

"Lloyd" <[email protected]>
wrote in
message
[email protected]...
I tried docmd.saverecord and got an error message
that
it
was not supported for this object (using
Access97). I
then tried the SaveRecord under docmd.MenuItem.
I
am
confident that I am getting the data saved, it
simply
isn't displaying on my form. I can simply
minimize
and
restore the form and the data is displayed.

Any additional thoughts?

Thanks, Lloyd

-----Original Message-----
Ah! The oh-so-common mistake of thinking that
DoCmd.Save
will save data!
It actually saves design changes.
Try DoCmd.SaveRecord


"Lloyd"
wrote in
message
[email protected]...
I have created a command button and written a
series of
If
ISNull statements to update address data from
one
table
to
another. (The information is often, but not
always
the
same.) A sample is shown below.

When I click the button, the data seems
to
be
updated,
but
does not show up on the current form
until
I
close
out
of
the record and reopen it. Can someone suggest
the
function I need to use to get the form to
display
the
new
data when the command button has been used?

Thanks, Lloyd

If IsNull(Forms![frmGrantSumDE].
[tblGrantSum.City])
Then
[tblGrantSum.City] = [Forms]!
[frmGrantSumDE].
[tblGrantee.City]
End If
If IsNull(Forms![frmGrantSumDE].
[tblGrantSum.Zip])
Then
[tblGrantSum.Zip] = [Forms]!
[frmGrantSumDE].
[tblGrantee.Zip]
End If
DoCmd.Save


.



.



.



.



.


.
 
M

MacDermott

How about the more complete syntax:

Forms!home!project.form!estimate.form!estimateLabor.RecordSource="laborQuery
"

Just to confirm: you have 3 subforms nested inside the main form (home)
home -> project -> estimate -> estimateLabor

BTW - have you said what version of Access you're using?

- Turtle
 
G

Guest

to confirm: you do have the nesting correct. i just
tried the new syntax. no go man. do you think i could
have a broken reference library or something?

also, i'm running 2002 with SP3.

Kevin
 
M

MacDermott

It never hurts to check your references;
do you know how to do that?

Here's what I'd try, though:
When your debugger stops, with your troubled line highlighted yellow,
open your immediate window if it's not already open. (Ctl-G is one way to do
that.)
Type in ?forms!home.name
It should echo back
home
Then type in ?forms!home!project.name
It should echo back
project
Continue to add items, one at a time, to your string, until you get an error
message instead of the name of your object.
This won't solve your problem right away, but at least it should tell us at
what property of what object Access is having trouble resolving...

- Turtle
 
K

kevin c

interesting little tool. never knew that there was
an 'immediate' window. i don't really understand how to
use it, but it seems like something i should learn more
about.

anyway, i did what you told me, and i was able to echo
back all the names of the related forms.

it' just so wierd how if when i go into the form that
should be updated (reflecting the new set of records) and
i view the record source via the properties window, once
i click back on the form, the records update. thta's so
wierd to me. it's like access does some special thing
updates the record set after you view the SQL. as if it
thinks there's a possibility that you changed it, so it
requeries. except when we requery, it doesn't work the
way i expect it to. you can tell when the requery runs,
because you see the records flash/refresh themselves,
even if they are the wrong records.

i have checked my references in other instances. it was
more of a compsarison between my database and another
until i got the problem fixed. references are a bit
confusing for me, because I have no idea which libraries
handle what. i was having some trouble with some VB
commands last time, and so i eventually figured out that
i wasn't including some VB library. I have no idea how
i'd approach this one though.

kevin
 
M

MacDermott

Yes, I use the immediate window a lot for debugging.
? and a variable will return its value.
You can even execute code from the immediate window;
if you have a variable i, you can type in
i=i+1 (return)
after that you'll find the value of i is one greater than it was.

So, are you saying that when you type in
?Forms!home!project!estimate!estimateLabor.Name
you get
estimateLabor
but when you type in
?Forms!home!project!estimate!estimateLabor.RecordSource
you get an error message?

As for references, go to Tools - References from any code window.
First look if anything is marked MISSING.
If so, remove the check mark next to it.
Close the dialog by clicking OK (not the x in the corner), then run your
code again and see if you still get the error.
If so, re-open Tools - References, and make a list of all the items with
checks.
Remove any you can. (some can't be removed)
Then add them back in their original order.
Close the dialog box as before, and try running your code.
If references were the problem, that should take care of it.
(You might want to save these instructions, in case you run into the
problem again.)

HTH
- Turtle
 
K

kevin c

yes, i'll be sure to save this message. thanks for the
immediate window tips... and yes, when i type ?Forms!
home!project!estimate!estimateLabor.RecordSource, i get
an error message. what does that mean?

kevin
 
M

MacDermott

Sorry if this is getting repetitious, but what about these variations:
?Forms!home!project!estimate!estimateLabor.form.RecordSource
?Forms!home!project!estimate!estimateLabor.form.name

If the error is "object doesn't support this property", it means that Access
doesn't think that estimateLabor is something that has a RecordSource
property.

- Turtle
 

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