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 6 2609
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
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
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
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
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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.
|
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...
|
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...
|
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.
| |
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
|
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
|
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
|
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:
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |