473,695 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

go to a record in a form

hey.... i have a duplicate record issue i could use some help with. on a
form that has 2 unbound controls, txtboxyear and cboxmonth, together will
automatically fill in an invisible txtboxdate that is bound to a table and
has no duplicates allowed. the problem is that there are 30 or so other
controls here to be filled in and if the user selects a year and month that
already has a record created, she/he won't know it until access tries to save
the record, then it will tell them that that record already exists.

how can i set things up so that when txtboxyear and cboxmonth are filled in,
if there's a record with that date already, it just goes to that record
automatically?

the problem i ran into when i tried findrecord is that it won't let the form
display another record because the month and year controls together form a
duplicate record and it won't go to another record without taking care of the
duplicate issue first. thanks.

--
Greg

Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200604/1
Apr 29 '06 #1
6 2603
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()

Me.Recordset.Fi ndFirst "YearMonthF ield = '" _
Me!txtboxyear & Me!cobxmonth & "'"
If Me.Recordset.No Match 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 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
"ka******@comca st.net via AccessMonster.c om" <u15580@uwe> wrote in message
news:5f7fda090a 0ae@uwe...
hey.... i have a duplicate record issue i could use some help with. on a
form that has 2 unbound controls, txtboxyear and cboxmonth, together will
automatically fill in an invisible txtboxdate that is bound to a table and
has no duplicates allowed. the problem is that there are 30 or so other
controls here to be filled in and if the user selects a year and month that already has a record created, she/he won't know it until access tries to save the record, then it will tell them that that record already exists.

how can i set things up so that when txtboxyear and cboxmonth are filled in, if there's a record with that date already, it just goes to that record
automatically?

the problem i ran into when i tried findrecord is that it won't let the form display another record because the month and year controls together form a
duplicate record and it won't go to another record without taking care of the duplicate issue first. thanks.

--
Greg

Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200604/1

Apr 29 '06 #2
tina... it's not working quite yet. this is what i have:

Private Sub isFindDups()
Dim strwhere
Me.Recordset.Fi ndFirst "date = #" & Me.txtboxdate & "#"
If Me.Recordset.No Match Then
If IsNull(Me.txtbo xyear) = False Then
strwhere = CDate(Me.cboxmo nth & " 1, " & Me.txtboxyear)
End If
If IsNull(Me.cboxm onth) = False Then
strwhere = CDate(Me.cboxmo nth & " 1, " & Me.txtboxyear)
End If
Me.txtboxdate = strwhere
End If
End Sub

and

Private Sub cboxmonth_After Update()
If IsNull(Me.txtbo xyear) = False Then
Call isFindDups
End If
End Sub

and

Private Sub txtboxyear_Afte rUpdate()
Dim strdate As Date

If IsNull(Me.cboxm onth) = 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, that's
when your code executes and i get the error. can you see where my disconnect
is?

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 from
the AfterUpdate event of *both* of the unbound controls.

Private Sub isFindDups()

Me.Recordset.Fi ndFirst "YearMonthF ield = '" _
Me!txtboxyear & Me!cobxmonth & "'"
If Me.Recordset.No Match 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 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
hey.... i have a duplicate record issue i could use some help with. on a
form that has 2 unbound controls, txtboxyear and cboxmonth, together will

[quoted text clipped - 12 lines]
duplicate record and it won't go to another record without taking care of the
duplicate issue first. thanks.


--
Greg

Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200605/1
May 1 '06 #3
kao, i'm really sorry - i posted the code *without* the "controllin g" 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!txtbo xyear) And _
Not IsNull(Me!cboxm onth) Then
Me.Recordset.Fi ndFirst "YearMonthF ield = '" _
Me!txtboxyear & Me!cboxmonth & "'"
If Me.Recordset.No Match 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
"ka******@comca st.net via AccessMonster.c om" <u15580@uwe> wrote in message
news:5f9bdf9ae3 0ad@uwe...
tina... it's not working quite yet. this is what i have:

Private Sub isFindDups()
Dim strwhere
Me.Recordset.Fi ndFirst "date = #" & Me.txtboxdate & "#"
If Me.Recordset.No Match Then
If IsNull(Me.txtbo xyear) = False Then
strwhere = CDate(Me.cboxmo nth & " 1, " & Me.txtboxyear)
End If
If IsNull(Me.cboxm onth) = False Then
strwhere = CDate(Me.cboxmo nth & " 1, " & Me.txtboxyear)
End If
Me.txtboxdate = strwhere
End If
End Sub

and

Private Sub cboxmonth_After Update()
If IsNull(Me.txtbo xyear) = False Then
Call isFindDups
End If
End Sub

and

Private Sub txtboxyear_Afte rUpdate()
Dim strdate As Date

If IsNull(Me.cboxm onth) = 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, that's when your code executes and i get the error. can you see where my disconnect is?

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 fromthe AfterUpdate event of *both* of the unbound controls.

Private Sub isFindDups()

Me.Recordset.Fi ndFirst "YearMonthF ield = '" _
Me!txtboxyear & Me!cobxmonth & "'"
If Me.Recordset.No Match 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 abovecode 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 invisiblecontrol 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 a form that has 2 unbound controls, txtboxyear and cboxmonth, together will
[quoted text clipped - 12 lines]
duplicate record and it won't go to another record without taking care

of the duplicate issue first. thanks.


--
Greg

Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200605/1

May 2 '06 #4
tina.... truthfully, i thought that might be the case -- it needed a
conditional statement before the findfirst line of code -- but i've only been
doing this since september and have never coded before so i didn't know. but
it did play with it for a while that way before my reply to tell you that it
wasn't working, to no avail. i followed your code which is a little cleaner
than what i had and i got the exact same error message and the exact same
issue with it not executing the code on the first go around but only after
you change either the month or year a 2nd time. sorry, but this didn't fix
the issue.

Private Sub isFindDups()
Dim strwhere
If Not IsNull(Me.txtbo xyear) And Not IsNull(Me.cboxm onth) Then
Me.Recordset.Fi ndFirst "date = #" & Me.txtboxdate & "#"
If Me.Recordset.No Match Then
If IsNull(Me.txtbo xyear) = False Then
strwhere = CDate(Me.cboxmo nth & " 1, " & Me.txtboxyear)
End If
If IsNull(Me.cboxm onth) = False Then
strwhere = CDate(Me.cboxmo nth & " 1, " & Me.txtboxyear)
End If
Me.txtboxdate = strwhere
End If
End If
End Sub

tina wrote:
kao, i'm really sorry - i posted the code *without* the "controllin g" 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!txtbo xyear) And _
Not IsNull(Me!cboxm onth) Then
Me.Recordset.Fi ndFirst "YearMonthF ield = '" _
Me!txtboxyear & Me!cboxmonth & "'"
If Me.Recordset.No Match 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
tina... it's not working quite yet. this is what i have:

[quoted text clipped - 70 lines]
>> duplicate record and it won't go to another record without taking care of the
>> duplicate issue first. thanks.


--
Greg

Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200605/1
May 2 '06 #5
hey.. i've been playing more and here's the newest. i tried this on a
different form that only has the year as the bound control, both in the
before and after update events. i get the same result each time -- the
action was cancelled by an associated event. i hope this new info helps.

Private Sub txtboxyear_Afte rUpdate()
Dim strwhere
strwhere = Me.txtboxyear
Me.Recordset.Fi ndfirst "year = " & strwhere
If Me.Recordset.No Match Then
Me.txtboxyear = strwhere
End If
End Sub

OR

Private Sub txtboxyear_Befo reUpdate(Cancel As Integer)
If Not IsNull(DLookup( "[year]", "tblusedforecas t", "[year] = " & Me.
txtboxyear)) Then
Me.Recordset.fi ndfirst "year = " & Me.txtboxyear
End If
End Sub

tina wrote:
kao, i'm really sorry - i posted the code *without* the "controllin g" 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!txtbo xyear) And _
Not IsNull(Me!cboxm onth) Then
Me.Recordset.Fi ndFirst "YearMonthF ield = '" _
Me!txtboxyear & Me!cboxmonth & "'"
If Me.Recordset.No Match 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
tina... it's not working quite yet. this is what i have:

[quoted text clipped - 70 lines]
>> duplicate record and it won't go to another record without taking care of the
>> duplicate issue first. thanks.


--
Greg

Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200605/1
May 3 '06 #6
okay, i read your second thread (posted several hours after this one), but
let's stick with this one for the moment. i don't think you're following
quite what i'm intending for the code to do - or perhaps i'm not quite
following what you want the code to do. so i've got a few questions for you:

1. your initial post said "2 unbound controls, txtboxyear and cboxmonth,
together will automatically fill in an invisible txtboxdate that is bound to
a table". txtboxdate is bound to a *field* in a table, correct? if the
field's name is "date", you should change it (see
http://home.att.net/~california.db/tips.html#aTip5 for more information).
if the field's name is not "date", then what is it? also , is the field's
data type Date/Time?
2. how are you combining the values in txtboxyear and cboxmonth to get a
single value that you use to populate the invisible date field? i assume
you're doing that with VBA code, so please post the expression you're using.

hth
"ka******@comca st.net via AccessMonster.c om" <u15580@uwe> wrote in message
news:5fa7058263 a26@uwe...
tina.... truthfully, i thought that might be the case -- it needed a
conditional statement before the findfirst line of code -- but i've only been doing this since september and have never coded before so i didn't know. but it did play with it for a while that way before my reply to tell you that it wasn't working, to no avail. i followed your code which is a little cleaner than what i had and i got the exact same error message and the exact same
issue with it not executing the code on the first go around but only after
you change either the month or year a 2nd time. sorry, but this didn't fix the issue.

Private Sub isFindDups()
Dim strwhere
If Not IsNull(Me.txtbo xyear) And Not IsNull(Me.cboxm onth) Then
Me.Recordset.Fi ndFirst "date = #" & Me.txtboxdate & "#"
If Me.Recordset.No Match Then
If IsNull(Me.txtbo xyear) = False Then
strwhere = CDate(Me.cboxmo nth & " 1, " & Me.txtboxyear)
End If
If IsNull(Me.cboxm onth) = False Then
strwhere = CDate(Me.cboxmo nth & " 1, " & Me.txtboxyear)
End If
Me.txtboxdate = strwhere
End If
End If
End Sub

tina wrote:
kao, i'm really sorry - i posted the code *without* the "controllin g" 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 correctedcode. 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 fromthe AfterUpdate event of *both* of the unbound controls.

Private Sub isFindDups()

If Not IsNull(Me!txtbo xyear) And _
Not IsNull(Me!cboxm onth) Then
Me.Recordset.Fi ndFirst "YearMonthF ield = '" _
Me!txtboxyear & Me!cboxmonth & "'"
If Me.Recordset.No Match 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 abovecode 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 invisiblecontrol is set in the *current* record (presumably a new record).

*********
hth
tina... it's not working quite yet. this is what i have:

[quoted text clipped - 70 lines]
>> duplicate record and it won't go to another record without taking care of the >> duplicate issue first. thanks.


--
Greg

Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200605/1

May 3 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4755
by: Skully Matjas | last post by:
I am using the following code (created by the wizard) to allow to bring my form to a particular entery. But when I edit the entery (ex: put new information into a blank cell), it puts that record onto the bottom of the list (even though it keeps its record number). Also, There are certin names that i click on the list, and it will not bring it up, rather it brings to the first record (no matter how many times i try going to that...
3
4751
by: William Wisnieski | last post by:
Hello Everyone, Access 2000, I have a main unbound form with a bound datasheet subform . The subform is bound to a query that returns records based on criteria in the main form. The user then double clicks a row on the datasheet subform to open yet another form bound to a table . These two forms are linked by the field. So far so good.
1
2476
by: Steve | last post by:
I have a form with about 30 fields. Much of data entry for this form involves the same data for many of the fields. To save typing time, in the form's AfterUpdate event I run a procedure that sets the defaultvalue property of each field to the value of that field in the last saved record. Essentially what happens is when a record is saved it becomes the default new record in the form. I have some comboboxes on the form that draw their data...
15
4654
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any field to start. If I edit that field and then click on the new record button in the navigation buttons, the form goes to a new record and each field has the default value of the previous record. If I put the focus in any field to start, edit that...
8
12099
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the combobox. What is the solution? Thank you in advance.
12
12938
by: swingingming | last post by:
Hi, in the NorthWind sample database, when clicking on the next navigation button on the new order record with nothing on the subform (order details), we got an order with nothing ordered. How can we prevent this from happening? Thanks. ming
19
3472
by: davidgordon | last post by:
Hi, I need some pointers/help on how to do the following if it possible: In my access db, I have the following: Tables: Products, Sub-Assembly, Product-Pack Table, Products
7
4537
by: john | last post by:
In my form I have a master table and a details table linked 1xM. I can search through the whole parent table but I also like to be able to search through the child table fields to find parent records. Should I design a new form for this or can I somehow make this work in the same form. Thanks in advance, john
10
15322
by: sara | last post by:
Hi - I have been struggling with solution ideas for this now for almost 2 weeks, and have not been able to figure this out. I have a user who creates a Purchase Order (tblPOData). In some circumstances, this or another user must create an invoice to go with the PO (I know - that makes no sense, but this is the business case). I have the user go to a form to create the invoice:
3
2436
prn
by: prn | last post by:
Hi folks, I've got something that's driving me crazy here. If you don't want to read a long explanation, this is not the post for you. My problematic Access app is a DB for keeping track of software test data. Each instance of a test is associated with a "test case", that is, a test item. Each test instance (or "run") may have a number of other characteristics too, such as browser used, OS (XP, Vista, Linux, Mac OSX, etc.), etc., but for...
0
8630
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9115
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8982
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8825
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5839
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4340
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4579
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3003
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2272
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.