Re: go to a record in a form
- From: "tina" <nospam@xxxxxxxxxxx>
- Date: Tue, 02 May 2006 03:12:57 GMT
kao, i'm really sorry - i posted the code *without* the "controlling" If
statement. hate to say this, but try deleting the code you wrote, and
starting over. below is a re-post of my initial response BUT with corrected
code. follow my directions again, and see if it'll work for you this time.
***********
well, since you're starting the data entry by entering values in two
*unbound* controls, that simplifies things considerably. try adding the
following procedure to the form's module, and then call the procedure from
the AfterUpdate event of *both* of the unbound controls.
Private Sub isFindDups()
If Not IsNull(Me!txtboxyear) And _
Not IsNull(Me!cboxmonth) Then
Me.Recordset.FindFirst "YearMonthField = '" _
Me!txtboxyear & Me!cboxmonth & "'"
If Me.Recordset.NoMatch Then
' put here the code to fill in the invisible txtboxdate
' control in the form.
End If
End If
End Sub
substitute the correct control and field names, of course. also, the above
code assumes that the "year/month field" in the table is a Text data type,
and that the value is built as "year first, then month, with no spaces in
the text". adjust the code as necessary, if your setup is different.
if both the year and month controls on the form have values entered, the
code searches the form's Recordset for a matching record. if a match is
found, the focus moves to that record. otherwise, the value of the invisible
control is set in the *current* record (presumably a new record).
*********
hth
"kaosyeti@xxxxxxxxxxx via AccessMonster.com" <u15580@uwe> wrote in message
news:5f9bdf9ae30ad@xxxxxx
tina... it's not working quite yet. this is what i have:that's
Private Sub isFindDups()
Dim strwhere
Me.Recordset.FindFirst "date = #" & Me.txtboxdate & "#"
If Me.Recordset.NoMatch Then
If IsNull(Me.txtboxyear) = False Then
strwhere = CDate(Me.cboxmonth & " 1, " & Me.txtboxyear)
End If
If IsNull(Me.cboxmonth) = False Then
strwhere = CDate(Me.cboxmonth & " 1, " & Me.txtboxyear)
End If
Me.txtboxdate = strwhere
End If
End Sub
and
Private Sub cboxmonth_AfterUpdate()
If IsNull(Me.txtboxyear) = False Then
Call isFindDups
End If
End Sub
and
Private Sub txtboxyear_AfterUpdate()
Dim strdate As Date
If IsNull(Me.cboxmonth) = False Then
Call isFindDups
End If
End Sub
and the message it gives me is that this action has been cancelled by an
associated event. the debugger opens on the first line of isFindDups().
also, when i enter the year and month, txtboxdate DOES fill itself in,
however nothing happens. then if i change either the year or month,
when your code executes and i get the error. can you see where mydisconnect
is?from
tina wrote:
well, since you're starting the data entry by entering values in two
*unbound* controls, that simplifies things considerably. try adding the
following procedure to the form's module, and then call the procedure
abovethe AfterUpdate event of *both* of the unbound controls.
Private Sub isFindDups()
Me.Recordset.FindFirst "YearMonthField = '" _
Me!txtboxyear & Me!cobxmonth & "'"
If Me.Recordset.NoMatch Then
' put here the code to fill in the invisible txtboxdate
' control in the form.
End If
End Sub
substitute the correct control and field names, of course. also, the
type,code assumes that the "year/month field" in the table is a Text data
invisibleand that the value is built as "year first, then month, with no spaces in
the text". adjust the code as necessary, if your setup is different.
if both the year and month controls on the form have values entered, the
code searches the form's Recordset for a matching record. if a match is
found, the focus moves to that record, otherwise the value of the
acontrol is set in the *current* record (presumably a new record).
hth
hey.... i have a duplicate record issue i could use some help with. on
willform that has 2 unbound controls, txtboxyear and cboxmonth, together
of the[quoted text clipped - 12 lines]
duplicate record and it won't go to another record without taking care
duplicate issue first. thanks.
--
Greg
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-access/200605/1
.
- Follow-Ups:
- Re: go to a record in a form
- From: kaosyeti@xxxxxxxxxxx via AccessMonster.com
- Re: go to a record in a form
- From: kaosyeti@xxxxxxxxxxx via AccessMonster.com
- Re: go to a record in a form
- References:
- Re: go to a record in a form
- From: kaosyeti@xxxxxxxxxxx via AccessMonster.com
- Re: go to a record in a form
- Prev by Date: Re: Help with Expression within Query
- Next by Date: Re: automation confusion
- Previous by thread: Re: go to a record in a form
- Next by thread: Re: go to a record in a form
- Index(es):
Relevant Pages
|