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@comcast.net via AccessMonster.com" <u15580@uwe> wrote in message
news:5f9bdf9ae30ad@uwe...[color=blue]
> tina... it's not working quite yet. this is what i have:
>
> 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,[/color]
that's[color=blue]
> when your code executes and i get the error. can you see where my[/color]
disconnect[color=blue]
> is?
>
> tina wrote:[color=green]
> >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[/color][/color]
from[color=blue][color=green]
> >the 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[/color][/color]
above[color=blue][color=green]
> >code assumes that the "year/month field" in the table is a Text data[/color][/color]
type,[color=blue][color=green]
> >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[/color][/color]
invisible[color=blue][color=green]
> >control is set in the *current* record (presumably a new record).
> >
> >hth
> >[color=darkred]
> >> hey.... i have a duplicate record issue i could use some help with. on[/color][/color][/color]
a[color=blue][color=green][color=darkred]
> >> form that has 2 unbound controls, txtboxyear and cboxmonth, together[/color][/color][/color]
will[color=blue][color=green]
> >[quoted text clipped - 12 lines][color=darkred]
> >> duplicate record and it won't go to another record without taking care[/color][/color][/color]
of the[color=blue][color=green][color=darkred]
> >> duplicate issue first. thanks.[/color][/color]
>
> --
> Greg
>
> Message posted via AccessMonster.com
>
http://www.accessmonster.com/Uwe/For...ccess/200605/1[/color]