Re-post Need help with this one

  • Thread starter Thread starter Syd
  • Start date Start date
S

Syd

I have a Main (parent) form which does a swapping of sub-
forms in a control called: "Embed_FormsSwap" The (child
forms are called: "A", "B", "C", "D" and so on. On each of
these (child forms) are controls for setting Day or Night
shift data entries called: "cboDayShift"
and "cboNightShift". Now I also have check boxes
called "chkHasDataOne" and "chkHasDataTwo" that get set to
=-1 every time the "cboDayShift" or "cboNightShift" drop
downs has a value or = 0 if there is no data.

These controls "cboDayShift" drop down
sets "chkHasDataOne" and "cboNightShift" Drop down
sets "chkHasDataTwo"

What I'd like to do is if the "cboDayShift" has a value
and the checkbox "chkHasDataOne" is set to =-1 and
the "cboNightShift" has no value and it's corresponding
checkbox "chkHasDataTwo" is = 0 have the form go to the
last incomplete record when it's re-opened, allowing
the "cboNightShift" to enter their data for the that shift
completing the record. However, it both "chkHasDataOne"
and "chkHasDataTwo" are equal to -1, have the form open to
acNewrec status.

Here is a sample of the code I have now, it works
intermittently.

If Me![chkHasDataOne] = -1 And Me![chkHasDataTwo] = 0 Then
DoCmd.GoToRecord , , acLast
Exit Sub
End If


If Me![chkHasDataOne] = -1 And Me![chkHasDataTwo] = -1 Then
DoCmd.GoToRecord , , acNewRec
Exit Sub
End If

Any idea on changes or assitance to make it work more
effeciently will be appreciated.

Thanks,.....
 
Hi,
If I understand you correctly, your code has to check the table where this data is stored,
not the values on the form.
You could use FindFirst on the form's recordset clone.

*air code*
Dim rs As Dao.Recordset

Set rs = Me.RecordsetClone

rs.FindFirst "fieldHasDataOne = -1 And " & _
"FieldHasDataTwo = 0"

If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
Else
DoCmd.GoToRecord , , acNewRec
End If

Set rs = Nothing

Substutute the correct filed names
 
Dan:

Thanks, for responding to my re-post. It worked!


-----Original Message-----
Hi,
If I understand you correctly, your code has to check the
table where this data is stored,
not the values on the form.
You could use FindFirst on the form's recordset clone.

*air code*
Dim rs As Dao.Recordset

Set rs = Me.RecordsetClone

rs.FindFirst "fieldHasDataOne = -1 And " & _
"FieldHasDataTwo = 0"

If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
Else
DoCmd.GoToRecord , , acNewRec
End If

Set rs = Nothing

Substutute the correct filed names


--
HTH
Dan Artuso, Access MVP


"Syd" <anonymous@discussions.microsoft.com> wrote in
message news:07e201c3c624$13689850$a501280a@phx.gbl...
I have a Main (parent) form which does a swapping of sub-
forms in a control called: "Embed_FormsSwap" The (child
forms are called: "A", "B", "C", "D" and so on. On each of
these (child forms) are controls for setting Day or Night
shift data entries called: "cboDayShift"
and "cboNightShift". Now I also have check boxes
called "chkHasDataOne" and "chkHasDataTwo" that get set to
=-1 every time the "cboDayShift" or "cboNightShift" drop
downs has a value or = 0 if there is no data.

These controls "cboDayShift" drop down
sets "chkHasDataOne" and "cboNightShift" Drop down
sets "chkHasDataTwo"

What I'd like to do is if the "cboDayShift" has a value
and the checkbox "chkHasDataOne" is set to =-1 and
the "cboNightShift" has no value and it's corresponding
checkbox "chkHasDataTwo" is = 0 have the form go to the
last incomplete record when it's re-opened, allowing
the "cboNightShift" to enter their data for the that shift
completing the record. However, it both "chkHasDataOne"
and "chkHasDataTwo" are equal to -1, have the form open to
acNewrec status.

Here is a sample of the code I have now, it works
intermittently.

If Me![chkHasDataOne] = -1 And Me![chkHasDataTwo] = 0 Then
DoCmd.GoToRecord , , acLast
Exit Sub
End If


If Me![chkHasDataOne] = -1 And Me![chkHasDataTwo] = -1 Then
DoCmd.GoToRecord , , acNewRec
Exit Sub
End If

Any idea on changes or assitance to make it work more
effeciently will be appreciated.

Thanks,.....


.
 
Back
Top