Me.Refresh works sometimes??? Please help!

G

Gina Whipp

Hey All,

I have Me.Refresh in two places, the first example works but second does not
and unless I rem it out the code won't compile. Can someone tell me why?

Thanks,
Gina Whipp

1st Example: This works...

If IsNull(Me.txtNonConformanceID) Then
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID SET
tblGetAUPReferenceID.garAUPReferenceID = [garAUPReferenceID]+1 WHERE
(((tblGetAUPReferenceID.garCustomerID) =
[Forms]![sfrLiftNonConformance]![txtCustomerID]));"
DoCmd.RunSQL "INSERT INTO tblNonConformance ( ncAUPReferenceID )
SELECT tblGetAUPReferenceID.garAUPReferenceID FROM tblGetAUPReferenceID
INNER JOIN qryLiftNonConformance ON tblGetAUPReferenceID.garCustomerID =
qryLiftNonConformance.crCustomerID WHERE
(((qryLiftNonConformance.lID)=[Forms]![sfrLiftNonConformance]![txtID]));"
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID INNER JOIN
qryLiftNonConformance ON tblGetAUPReferenceID.garCustomerID =
qryLiftNonConformance.crCustomerID SET
qryLiftNonConformance.lNonConformanceID =
[tblGetAUPReferenceID]![garAUPReferenceID] WHERE
(((qryLiftNonConformance.lID)=[Forms]![sfrLiftNonConformance]![txtID]));"
Me.Refresh
DoCmd.SetWarnings True

DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
Else
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
End If

2nd Example: This doesn't work...

If IsNull(Me.txtNonConformanceID) Then
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID SET
tblGetAUPReferenceID.garAUPReferenceID = [garAUPReferenceID]+1 WHERE
(((tblGetAUPReferenceID.garCustomerID) =
[Forms]![frmCoilReceipt]![cboCustomerID]));"
DoCmd.RunSQL "INSERT INTO tblNonConformance (
ncAUPReferenceID )SELECT tblGetAUPReferenceID.garAUPReferenceID FROM
tblGetAUPReferenceID INNER JOIN tblCoilReceiving ON
tblGetAUPReferenceID.garCustomerID = tblCoilReceiving.crCustomerID WHERE
(((tblCoilReceiving.crCoilID) = [Forms]![frmCoilReceipt]![cboCoilID]));"
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID INNER JOIN
tblCoilReceiving ON tblGetAUPReferenceID.garCustomerID =
tblCoilReceiving.crCustomerID SET tblCoilReceiving.crNonConformanceID =
[tblGetAUPReferenceID]![garAUPReferenceID] WHERE
(((tblCoilReceiving.crCoilID) = [Forms]![frmCoilReceipt]![cboCoilID]));"
<<<<<<Me.Refresh NOT WORKING>>>>>>
DoCmd.SetWarnings True
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
Me.cmdUndoNC.Enabled = True
Else
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
End If
 
R

Ray Cacciatore

Me.Refresh refreshes the form. So it basically requeries its Recordsource
property. Where did you put this code that you show?

Ray
 
G

Gina Whipp

If you look below you will see <<<<<< >>>>> that's where it is. And yes I
know it requeries the recordsource that is exactly what I want it to do.


Ray Cacciatore said:
Me.Refresh refreshes the form. So it basically requeries its Recordsource
property. Where did you put this code that you show?

Ray


Gina Whipp said:
Hey All,

I have Me.Refresh in two places, the first example works but second does
not
and unless I rem it out the code won't compile. Can someone tell me why?

Thanks,
Gina Whipp

1st Example: This works...

If IsNull(Me.txtNonConformanceID) Then
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID SET
tblGetAUPReferenceID.garAUPReferenceID = [garAUPReferenceID]+1 WHERE
(((tblGetAUPReferenceID.garCustomerID) =
[Forms]![sfrLiftNonConformance]![txtCustomerID]));"
DoCmd.RunSQL "INSERT INTO tblNonConformance ( ncAUPReferenceID )
SELECT tblGetAUPReferenceID.garAUPReferenceID FROM tblGetAUPReferenceID
INNER JOIN qryLiftNonConformance ON tblGetAUPReferenceID.garCustomerID =
qryLiftNonConformance.crCustomerID WHERE
(((qryLiftNonConformance.lID)=[Forms]![sfrLiftNonConformance]![txtID]));"
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID INNER JOIN
qryLiftNonConformance ON tblGetAUPReferenceID.garCustomerID =
qryLiftNonConformance.crCustomerID SET
qryLiftNonConformance.lNonConformanceID =
[tblGetAUPReferenceID]![garAUPReferenceID] WHERE
(((qryLiftNonConformance.lID)=[Forms]![sfrLiftNonConformance]![txtID]));"
Me.Refresh
DoCmd.SetWarnings True

DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
Else
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
End If

2nd Example: This doesn't work...

If IsNull(Me.txtNonConformanceID) Then
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID SET
tblGetAUPReferenceID.garAUPReferenceID = [garAUPReferenceID]+1 WHERE
(((tblGetAUPReferenceID.garCustomerID) =
[Forms]![frmCoilReceipt]![cboCustomerID]));"
DoCmd.RunSQL "INSERT INTO tblNonConformance (
ncAUPReferenceID )SELECT tblGetAUPReferenceID.garAUPReferenceID FROM
tblGetAUPReferenceID INNER JOIN tblCoilReceiving ON
tblGetAUPReferenceID.garCustomerID = tblCoilReceiving.crCustomerID WHERE
(((tblCoilReceiving.crCoilID) = [Forms]![frmCoilReceipt]![cboCoilID]));"
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID INNER JOIN
tblCoilReceiving ON tblGetAUPReferenceID.garCustomerID =
tblCoilReceiving.crCustomerID SET tblCoilReceiving.crNonConformanceID =
[tblGetAUPReferenceID]![garAUPReferenceID] WHERE
(((tblCoilReceiving.crCoilID) = [Forms]![frmCoilReceipt]![cboCoilID]));"
<<<<<<Me.Refresh NOT WORKING>>>>>>
DoCmd.SetWarnings True
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
Me.cmdUndoNC.Enabled = True
Else
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
End If
 
G

Gina Whipp

The message when I try to compile is:

Compile Error:
Method or data member not found.

And that only happens on the second exapmle not the first example.

Thanks,
Gina Whipp

J. Goddard said:
What is the error message you get when it doesn't compile?

John


Gina said:
Hey All,

I have Me.Refresh in two places, the first example works but second does
not and unless I rem it out the code won't compile. Can someone tell me
why?

Thanks,
Gina Whipp

1st Example: This works...

If IsNull(Me.txtNonConformanceID) Then
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID SET
tblGetAUPReferenceID.garAUPReferenceID = [garAUPReferenceID]+1 WHERE
(((tblGetAUPReferenceID.garCustomerID) =
[Forms]![sfrLiftNonConformance]![txtCustomerID]));"
DoCmd.RunSQL "INSERT INTO tblNonConformance ( ncAUPReferenceID )
SELECT tblGetAUPReferenceID.garAUPReferenceID FROM tblGetAUPReferenceID
INNER JOIN qryLiftNonConformance ON tblGetAUPReferenceID.garCustomerID =
qryLiftNonConformance.crCustomerID WHERE
(((qryLiftNonConformance.lID)=[Forms]![sfrLiftNonConformance]![txtID]));"
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID INNER JOIN
qryLiftNonConformance ON tblGetAUPReferenceID.garCustomerID =
qryLiftNonConformance.crCustomerID SET
qryLiftNonConformance.lNonConformanceID =
[tblGetAUPReferenceID]![garAUPReferenceID] WHERE
(((qryLiftNonConformance.lID)=[Forms]![sfrLiftNonConformance]![txtID]));"
Me.Refresh
DoCmd.SetWarnings True

DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
Else
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
End If

2nd Example: This doesn't work...

If IsNull(Me.txtNonConformanceID) Then
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID SET
tblGetAUPReferenceID.garAUPReferenceID = [garAUPReferenceID]+1 WHERE
(((tblGetAUPReferenceID.garCustomerID) =
[Forms]![frmCoilReceipt]![cboCustomerID]));"
DoCmd.RunSQL "INSERT INTO tblNonConformance (
ncAUPReferenceID )SELECT tblGetAUPReferenceID.garAUPReferenceID FROM
tblGetAUPReferenceID INNER JOIN tblCoilReceiving ON
tblGetAUPReferenceID.garCustomerID = tblCoilReceiving.crCustomerID WHERE
(((tblCoilReceiving.crCoilID) = [Forms]![frmCoilReceipt]![cboCoilID]));"
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID INNER JOIN
tblCoilReceiving ON tblGetAUPReferenceID.garCustomerID =
tblCoilReceiving.crCustomerID SET tblCoilReceiving.crNonConformanceID =
[tblGetAUPReferenceID]![garAUPReferenceID] WHERE
(((tblCoilReceiving.crCoilID) = [Forms]![frmCoilReceipt]![cboCoilID]));"
<<<<<<Me.Refresh NOT WORKING>>>>>>
DoCmd.SetWarnings True
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
Me.cmdUndoNC.Enabled = True
Else
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
End If
 
G

Gina Whipp

I hope this doesn't go twice, got a message that is couldn't post.

Message I get for second example only:

Compile Error:
Method or data member not found.

Thansk,
Gina Whipp


J. Goddard said:
What is the error message you get when it doesn't compile?

John


Gina said:
Hey All,

I have Me.Refresh in two places, the first example works but second does
not and unless I rem it out the code won't compile. Can someone tell me
why?

Thanks,
Gina Whipp

1st Example: This works...

If IsNull(Me.txtNonConformanceID) Then
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID SET
tblGetAUPReferenceID.garAUPReferenceID = [garAUPReferenceID]+1 WHERE
(((tblGetAUPReferenceID.garCustomerID) =
[Forms]![sfrLiftNonConformance]![txtCustomerID]));"
DoCmd.RunSQL "INSERT INTO tblNonConformance ( ncAUPReferenceID )
SELECT tblGetAUPReferenceID.garAUPReferenceID FROM tblGetAUPReferenceID
INNER JOIN qryLiftNonConformance ON tblGetAUPReferenceID.garCustomerID =
qryLiftNonConformance.crCustomerID WHERE
(((qryLiftNonConformance.lID)=[Forms]![sfrLiftNonConformance]![txtID]));"
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID INNER JOIN
qryLiftNonConformance ON tblGetAUPReferenceID.garCustomerID =
qryLiftNonConformance.crCustomerID SET
qryLiftNonConformance.lNonConformanceID =
[tblGetAUPReferenceID]![garAUPReferenceID] WHERE
(((qryLiftNonConformance.lID)=[Forms]![sfrLiftNonConformance]![txtID]));"
Me.Refresh
DoCmd.SetWarnings True

DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
Else
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
End If

2nd Example: This doesn't work...

If IsNull(Me.txtNonConformanceID) Then
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID SET
tblGetAUPReferenceID.garAUPReferenceID = [garAUPReferenceID]+1 WHERE
(((tblGetAUPReferenceID.garCustomerID) =
[Forms]![frmCoilReceipt]![cboCustomerID]));"
DoCmd.RunSQL "INSERT INTO tblNonConformance (
ncAUPReferenceID )SELECT tblGetAUPReferenceID.garAUPReferenceID FROM
tblGetAUPReferenceID INNER JOIN tblCoilReceiving ON
tblGetAUPReferenceID.garCustomerID = tblCoilReceiving.crCustomerID WHERE
(((tblCoilReceiving.crCoilID) = [Forms]![frmCoilReceipt]![cboCoilID]));"
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID INNER JOIN
tblCoilReceiving ON tblGetAUPReferenceID.garCustomerID =
tblCoilReceiving.crCustomerID SET tblCoilReceiving.crNonConformanceID =
[tblGetAUPReferenceID]![garAUPReferenceID] WHERE
(((tblCoilReceiving.crCoilID) = [Forms]![frmCoilReceipt]![cboCoilID]));"
<<<<<<Me.Refresh NOT WORKING>>>>>>
DoCmd.SetWarnings True
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
Me.cmdUndoNC.Enabled = True
Else
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
End If
 
J

J. Goddard

Hi Gina -

What Ray meant was where are the 2 block of code you are showing? If
the second one is not in the code module for a form, it will not
compile, because it doesn't know what "Me." is.

Silly question, maybe - but did you try deleting the offending line
completely and retyping it? when all else fails....?

John


Gina said:
If you look below you will see <<<<<< >>>>> that's where it is. And yes I
know it requeries the recordsource that is exactly what I want it to do.


Me.Refresh refreshes the form. So it basically requeries its Recordsource
property. Where did you put this code that you show?

Ray


:

Hey All,

I have Me.Refresh in two places, the first example works but second does
not
and unless I rem it out the code won't compile. Can someone tell me why?

Thanks,
Gina Whipp

1st Example: This works...

If IsNull(Me.txtNonConformanceID) Then
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID SET
tblGetAUPReferenceID.garAUPReferenceID = [garAUPReferenceID]+1 WHERE
(((tblGetAUPReferenceID.garCustomerID) =
[Forms]![sfrLiftNonConformance]![txtCustomerID]));"
DoCmd.RunSQL "INSERT INTO tblNonConformance ( ncAUPReferenceID )
SELECT tblGetAUPReferenceID.garAUPReferenceID FROM tblGetAUPReferenceID
INNER JOIN qryLiftNonConformance ON tblGetAUPReferenceID.garCustomerID =
qryLiftNonConformance.crCustomerID WHERE
(((qryLiftNonConformance.lID)=[Forms]![sfrLiftNonConformance]![txtID]));"
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID INNER JOIN
qryLiftNonConformance ON tblGetAUPReferenceID.garCustomerID =
qryLiftNonConformance.crCustomerID SET
qryLiftNonConformance.lNonConformanceID =
[tblGetAUPReferenceID]![garAUPReferenceID] WHERE
(((qryLiftNonConformance.lID)=[Forms]![sfrLiftNonConformance]![txtID]));"
Me.Refresh
DoCmd.SetWarnings True

DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
Else
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
End If

2nd Example: This doesn't work...

If IsNull(Me.txtNonConformanceID) Then
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID SET
tblGetAUPReferenceID.garAUPReferenceID = [garAUPReferenceID]+1 WHERE
(((tblGetAUPReferenceID.garCustomerID) =
[Forms]![frmCoilReceipt]![cboCustomerID]));"
DoCmd.RunSQL "INSERT INTO tblNonConformance (
ncAUPReferenceID )SELECT tblGetAUPReferenceID.garAUPReferenceID FROM
tblGetAUPReferenceID INNER JOIN tblCoilReceiving ON
tblGetAUPReferenceID.garCustomerID = tblCoilReceiving.crCustomerID WHERE
(((tblCoilReceiving.crCoilID) = [Forms]![frmCoilReceipt]![cboCoilID]));"
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID INNER JOIN
tblCoilReceiving ON tblGetAUPReferenceID.garCustomerID =
tblCoilReceiving.crCustomerID SET tblCoilReceiving.crNonConformanceID =
[tblGetAUPReferenceID]![garAUPReferenceID] WHERE
(((tblCoilReceiving.crCoilID) = [Forms]![frmCoilReceipt]![cboCoilID]));"
<<<<<<Me.Refresh NOT WORKING>>>>>>
DoCmd.SetWarnings True
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
Me.cmdUndoNC.Enabled = True
Else
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
End If
 
G

Gina Whipp

Oops, silly me.... They are both in a code module for a
from..sfrLiftNonConformance and frmCoilReceipt. The one one frmCoilReceipt
is the one that refuses to work.

And yep, I tried deleting and what happens is on sfrLiftNonConformance I
type Me. and get the choice to Refresh, when I type Me. on frmCoilReceipt
the Refresh, Requery choices are not in that list, I don't know what the
difference is.

Thanks,
Gina Whipp



J. Goddard said:
Hi Gina -

What Ray meant was where are the 2 block of code you are showing? If the
second one is not in the code module for a form, it will not compile,
because it doesn't know what "Me." is.

Silly question, maybe - but did you try deleting the offending line
completely and retyping it? when all else fails....?

John


Gina said:
If you look below you will see <<<<<< >>>>> that's where it is. And
yes I know it requeries the recordsource that is exactly what I want it
to do.


Me.Refresh refreshes the form. So it basically requeries its Recordsource
property. Where did you put this code that you show?

Ray


:


Hey All,

I have Me.Refresh in two places, the first example works but second does
not
and unless I rem it out the code won't compile. Can someone tell me
why?

Thanks,
Gina Whipp

1st Example: This works...

If IsNull(Me.txtNonConformanceID) Then
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID SET
tblGetAUPReferenceID.garAUPReferenceID = [garAUPReferenceID]+1 WHERE
(((tblGetAUPReferenceID.garCustomerID) =
[Forms]![sfrLiftNonConformance]![txtCustomerID]));"
DoCmd.RunSQL "INSERT INTO tblNonConformance ( ncAUPReferenceID )
SELECT tblGetAUPReferenceID.garAUPReferenceID FROM tblGetAUPReferenceID
INNER JOIN qryLiftNonConformance ON tblGetAUPReferenceID.garCustomerID =
qryLiftNonConformance.crCustomerID WHERE
(((qryLiftNonConformance.lID)=[Forms]![sfrLiftNonConformance]![txtID]));"
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID INNER JOIN
qryLiftNonConformance ON tblGetAUPReferenceID.garCustomerID =
qryLiftNonConformance.crCustomerID SET
qryLiftNonConformance.lNonConformanceID =
[tblGetAUPReferenceID]![garAUPReferenceID] WHERE
(((qryLiftNonConformance.lID)=[Forms]![sfrLiftNonConformance]![txtID]));"
Me.Refresh
DoCmd.SetWarnings True

DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
Else
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
End If

2nd Example: This doesn't work...

If IsNull(Me.txtNonConformanceID) Then
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID SET
tblGetAUPReferenceID.garAUPReferenceID = [garAUPReferenceID]+1 WHERE
(((tblGetAUPReferenceID.garCustomerID) =
[Forms]![frmCoilReceipt]![cboCustomerID]));"
DoCmd.RunSQL "INSERT INTO tblNonConformance (
ncAUPReferenceID )SELECT tblGetAUPReferenceID.garAUPReferenceID FROM
tblGetAUPReferenceID INNER JOIN tblCoilReceiving ON
tblGetAUPReferenceID.garCustomerID = tblCoilReceiving.crCustomerID WHERE
(((tblCoilReceiving.crCoilID) = [Forms]![frmCoilReceipt]![cboCoilID]));"
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID INNER JOIN
tblCoilReceiving ON tblGetAUPReferenceID.garCustomerID =
tblCoilReceiving.crCustomerID SET tblCoilReceiving.crNonConformanceID =
[tblGetAUPReferenceID]![garAUPReferenceID] WHERE
(((tblCoilReceiving.crCoilID) = [Forms]![frmCoilReceipt]![cboCoilID]));"
<<<<<<Me.Refresh NOT WORKING>>>>>>
DoCmd.SetWarnings True
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
Me.cmdUndoNC.Enabled = True
Else
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
End If
 
J

J. Goddard

Hmmm - I don't see any difference either.

What happens if you replace Me.Refresh with
[Forms]![frmCoilReceipt].refresh ?

John




Gina said:
Oops, silly me.... They are both in a code module for a
from..sfrLiftNonConformance and frmCoilReceipt. The one one frmCoilReceipt
is the one that refuses to work.

And yep, I tried deleting and what happens is on sfrLiftNonConformance I
type Me. and get the choice to Refresh, when I type Me. on frmCoilReceipt
the Refresh, Requery choices are not in that list, I don't know what the
difference is.

Thanks,
Gina Whipp



Hi Gina -

What Ray meant was where are the 2 block of code you are showing? If the
second one is not in the code module for a form, it will not compile,
because it doesn't know what "Me." is.

Silly question, maybe - but did you try deleting the offending line
completely and retyping it? when all else fails....?

John


Gina Whipp wrote:

If you look below you will see <<<<<< >>>>> that's where it is. And
yes I know it requeries the recordsource that is exactly what I want it
to do.


message

Me.Refresh refreshes the form. So it basically requeries its Recordsource
property. Where did you put this code that you show?

Ray


:



Hey All,

I have Me.Refresh in two places, the first example works but second does
not
and unless I rem it out the code won't compile. Can someone tell me
why?

Thanks,
Gina Whipp

1st Example: This works...

If IsNull(Me.txtNonConformanceID) Then
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID SET
tblGetAUPReferenceID.garAUPReferenceID = [garAUPReferenceID]+1 WHERE
(((tblGetAUPReferenceID.garCustomerID) =
[Forms]![sfrLiftNonConformance]![txtCustomerID]));"
DoCmd.RunSQL "INSERT INTO tblNonConformance ( ncAUPReferenceID )
SELECT tblGetAUPReferenceID.garAUPReferenceID FROM tblGetAUPReferenceID
INNER JOIN qryLiftNonConformance ON tblGetAUPReferenceID.garCustomerID =
qryLiftNonConformance.crCustomerID WHERE
(((qryLiftNonConformance.lID)=[Forms]![sfrLiftNonConformance]![txtID]));"
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID INNER JOIN
qryLiftNonConformance ON tblGetAUPReferenceID.garCustomerID =
qryLiftNonConformance.crCustomerID SET
qryLiftNonConformance.lNonConformanceID =
[tblGetAUPReferenceID]![garAUPReferenceID] WHERE
(((qryLiftNonConformance.lID)=[Forms]![sfrLiftNonConformance]![txtID]));"
Me.Refresh
DoCmd.SetWarnings True

DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
Else
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
End If

2nd Example: This doesn't work...

If IsNull(Me.txtNonConformanceID) Then
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID SET
tblGetAUPReferenceID.garAUPReferenceID = [garAUPReferenceID]+1 WHERE
(((tblGetAUPReferenceID.garCustomerID) =
[Forms]![frmCoilReceipt]![cboCustomerID]));"
DoCmd.RunSQL "INSERT INTO tblNonConformance (
ncAUPReferenceID )SELECT tblGetAUPReferenceID.garAUPReferenceID FROM
tblGetAUPReferenceID INNER JOIN tblCoilReceiving ON
tblGetAUPReferenceID.garCustomerID = tblCoilReceiving.crCustomerID WHERE
(((tblCoilReceiving.crCoilID) = [Forms]![frmCoilReceipt]![cboCoilID]));"
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID INNER JOIN
tblCoilReceiving ON tblGetAUPReferenceID.garCustomerID =
tblCoilReceiving.crCustomerID SET tblCoilReceiving.crNonConformanceID =
[tblGetAUPReferenceID]![garAUPReferenceID] WHERE
(((tblCoilReceiving.crCoilID) = [Forms]![frmCoilReceipt]![cboCoilID]));"
<<<<<<Me.Refresh NOT WORKING>>>>>>
DoCmd.SetWarnings True
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
Me.cmdUndoNC.Enabled = True
Else
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
End If
 
G

Gina Whipp

Okay John, I'm losing my mind. After spending the day trying to figure out
what was wrong, I thought I'd try one more time before trying your
suggestion and guess what!!!! D-m thing works... Me.Refresh works just
fine. Thinking I might have a suttle form of corruption, going to import
all my objects into a new database and see what happens.

I will try your suggestion if it decides to 'act-up' again.

Thanks for all your help,
Gina Whipp


J. Goddard said:
Hmmm - I don't see any difference either.

What happens if you replace Me.Refresh with
[Forms]![frmCoilReceipt].refresh ?

John




Gina said:
Oops, silly me.... They are both in a code module for a
from..sfrLiftNonConformance and frmCoilReceipt. The one one
frmCoilReceipt is the one that refuses to work.

And yep, I tried deleting and what happens is on sfrLiftNonConformance I
type Me. and get the choice to Refresh, when I type Me. on frmCoilReceipt
the Refresh, Requery choices are not in that list, I don't know what the
difference is.

Thanks,
Gina Whipp



Hi Gina -

What Ray meant was where are the 2 block of code you are showing? If the
second one is not in the code module for a form, it will not compile,
because it doesn't know what "Me." is.

Silly question, maybe - but did you try deleting the offending line
completely and retyping it? when all else fails....?

John


Gina Whipp wrote:


If you look below you will see <<<<<< >>>>> that's where it is. And
yes I know it requeries the recordsource that is exactly what I want it
to do.


message

Me.Refresh refreshes the form. So it basically requeries its
Recordsource
property. Where did you put this code that you show?

Ray


:



Hey All,

I have Me.Refresh in two places, the first example works but second
does not
and unless I rem it out the code won't compile. Can someone tell me
why?

Thanks,
Gina Whipp

1st Example: This works...

If IsNull(Me.txtNonConformanceID) Then
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID SET
tblGetAUPReferenceID.garAUPReferenceID = [garAUPReferenceID]+1 WHERE
(((tblGetAUPReferenceID.garCustomerID) =
[Forms]![sfrLiftNonConformance]![txtCustomerID]));"
DoCmd.RunSQL "INSERT INTO tblNonConformance (
ncAUPReferenceID )
SELECT tblGetAUPReferenceID.garAUPReferenceID FROM
tblGetAUPReferenceID
INNER JOIN qryLiftNonConformance ON tblGetAUPReferenceID.garCustomerID
=
qryLiftNonConformance.crCustomerID WHERE
(((qryLiftNonConformance.lID)=[Forms]![sfrLiftNonConformance]![txtID]));"
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID INNER JOIN
qryLiftNonConformance ON tblGetAUPReferenceID.garCustomerID =
qryLiftNonConformance.crCustomerID SET
qryLiftNonConformance.lNonConformanceID =
[tblGetAUPReferenceID]![garAUPReferenceID] WHERE
(((qryLiftNonConformance.lID)=[Forms]![sfrLiftNonConformance]![txtID]));"
Me.Refresh
DoCmd.SetWarnings True

DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
Else
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
End If

2nd Example: This doesn't work...

If IsNull(Me.txtNonConformanceID) Then
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID SET
tblGetAUPReferenceID.garAUPReferenceID = [garAUPReferenceID]+1 WHERE
(((tblGetAUPReferenceID.garCustomerID) =
[Forms]![frmCoilReceipt]![cboCustomerID]));"
DoCmd.RunSQL "INSERT INTO tblNonConformance (
ncAUPReferenceID )SELECT tblGetAUPReferenceID.garAUPReferenceID FROM
tblGetAUPReferenceID INNER JOIN tblCoilReceiving ON
tblGetAUPReferenceID.garCustomerID = tblCoilReceiving.crCustomerID
WHERE
(((tblCoilReceiving.crCoilID) =
[Forms]![frmCoilReceipt]![cboCoilID]));"
DoCmd.RunSQL "UPDATE tblGetAUPReferenceID INNER JOIN
tblCoilReceiving ON tblGetAUPReferenceID.garCustomerID =
tblCoilReceiving.crCustomerID SET tblCoilReceiving.crNonConformanceID
=
[tblGetAUPReferenceID]![garAUPReferenceID] WHERE
(((tblCoilReceiving.crCoilID) =
[Forms]![frmCoilReceipt]![cboCoilID]));"
<<<<<<Me.Refresh NOT WORKING>>>>>>
DoCmd.SetWarnings True
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
Me.cmdUndoNC.Enabled = True
Else
DoCmd.OpenForm "frmNonConformance", , , "[ncAUPReferenceID]=" &
Me![txtNonConformanceID]
End If
 

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