473,770 Members | 4,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

trouble with next button on a filtered form

AccessIdiot
493 Contributor
Anyone getting sick of me yet? :D

I have a button on my form that opens a new form but with a filter:
Expand|Select|Wrap|Line Numbers
  1.     stDocName = "frm_Specimen_Entrainment"
  2.     stLinkCriteria = "[Entrainment_ID]=" & Me![Entrainment_ID]
  3.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  4.  
This works really well except that, as expected, I can't add new records. Interestingly, you can click the "next record" button and it will show a blank form (and then grey out) but the Entrainment_ID goes blank and the record doesn't get saved.

If I change the above code and pass the Entrainment_ID as OpenArgs then I can add a new record. However, I can keep hitting the next button as many times as I want and it keeps adding new records, whether I have actual data in there or not.

I am looking for something in between - the next button goes to a new record, then greys out so I can't keep adding new records until someone hits the "add new record" button.

Is this possible?

Thanks!
Apr 26 '07 #1
22 2087
Rabbit
12,516 Recognized Expert Moderator MVP
Anyone getting sick of me yet? :D

I have a button on my form that opens a new form but with a filter:
Expand|Select|Wrap|Line Numbers
  1.     stDocName = "frm_Specimen_Entrainment"
  2.     stLinkCriteria = "[Entrainment_ID]=" & Me![Entrainment_ID]
  3.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  4.  
This works really well except that, as expected, I can't add new records. Interestingly, you can click the "next record" button and it will show a blank form (and then grey out) but the Entrainment_ID goes blank and the record doesn't get saved.

If I change the above code and pass the Entrainment_ID as OpenArgs then I can add a new record. However, I can keep hitting the next button as many times as I want and it keeps adding new records, whether I have actual data in there or not.

I am looking for something in between - the next button goes to a new record, then greys out so I can't keep adding new records until someone hits the "add new record" button.

Is this possible?

Thanks!
Opening the form with the stLinkCriteria filter shouldn't prevent you from adding records.
Apr 26 '07 #2
AccessIdiot
493 Contributor
One would think! And yet that Entrainment_ID isn't getting populated on the new record.
Apr 26 '07 #3
Rabbit
12,516 Recognized Expert Moderator MVP
One would think! And yet that Entrainment_ID isn't getting populated on the new record.
It shouldn't, a filter doesn't limit what goes into a field.
Isn't that why you passed the Entrainment_ID in OpenArgs as well? So that you can assign it as the Entrainment_ID for new records? But of course that's also the reason why it keeps adding new records. Assigning it an entrainment_id saves it as a new record with just that one field.

What you could do is on form close, run a delete SQL that deletes all records where only the entrainment_id has data in it.
Apr 26 '07 #4
AccessIdiot
493 Contributor
Cool. I didn't realize that's what was happening. I figured once the correct Entrainment_ID was passed through the filter then one could keep going with that same Entrainment_ID.

How does one specify in the delete clause records that only contain the ID field? Do you have to cycle through all the controls and look for blanks?

thanks again for the help Rabbit. :)
Apr 26 '07 #5
Rabbit
12,516 Recognized Expert Moderator MVP
Cool. I didn't realize that's what was happening. I figured once the correct Entrainment_ID was passed through the filter then one could keep going with that same Entrainment_ID.

How does one specify in the delete clause records that only contain the ID field? Do you have to cycle through all the controls and look for blanks?

thanks again for the help Rabbit. :)
Not a problem.

It's not as easy as looking for records that only have info in the ID field. Rather you have to find records where the required fields are blank. Something along the lines of:
Expand|Select|Wrap|Line Numbers
  1. DELETE FROM tbl_Name
  2. WHERE Field1 Is Null AND Field2 Is Null AND Field3 Is Null;
Apr 26 '07 #6
AccessIdiot
493 Contributor
Yuck - there are lots of controls, and a subform to boot.

Pardon my ignorance but how do I create a SQL query in the On Close event? Can I do it in the VBA or do I create a macro or . . . ?
Apr 26 '07 #7
Rabbit
12,516 Recognized Expert Moderator MVP
Yuck - there are lots of controls, and a subform to boot.

Pardon my ignorance but how do I create a SQL query in the On Close event? Can I do it in the VBA or do I create a macro or . . . ?
You don't have to check every control, just enough of them to be sure that it was an accidental click of the create new record button.

But I doubt anyone's going to go on a clicking spree creating a bunch of mostly empty records.

There are two ways to do a query in VBA. One is to create the actual query in query design that does what you want. Then you open the query in VBA using.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenQuery "Query Name"
Or you can build the string yourself in VBA
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL "DELETE FROM ..."
Apr 26 '07 #8
AccessIdiot
493 Contributor
Ahh, DoCmd.RunSQL is what I was looking for. :)
Apr 26 '07 #9
AccessIdiot
493 Contributor
Hmmm, I must be doing something wrong. I get the pop up that says I"m about to delete 0 records from my table. Do I need to have the table name in front of each field name? My code right now is:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Close()
  2.     DoCmd.RunSQL "DELETE FROM tbl_Specimen_Replicate WHERE Species_ID Is Null AND Gender_ID Is Null AND Lifestage_ID Is Null AND Disp_Capture_ID Is Null AND Disp_Release_ID Is Null AND Anomalies Is Null AND Comments Is Null;"
  3. End Sub
Maybe I need
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Close()
  2.     DoCmd.RunSQL "DELETE FROM tbl_Specimen_Replicate WHERE tbl_Specimen_Replicate.Species_ID Is Null AND tbl_Specimen_Replicate.Gender_ID Is Null AND tbl_Specimen_Replicate.Lifestage_ID Is Null . . . etc"
  3. End Sub
?
Apr 26 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

8
2020
by: lawrence | last post by:
I'm a beginner with Javascript and especially cross-browser Javascript. I got this working in IE, but not in Netscape 7. It seems like, in Netscape, every time I click on a button, the focus shifts to that button, so there is no text to be selected. What should I do? Below you'll see some code that I have in one of my forms. I was hoping to have these buttons and when I click on them they would take selected text from a textarea box and...
1
2706
by: lawrence | last post by:
This PHP function prints out a bunch of Javascript (as you can see). This is all part of the open source weblog software of PDS (www.publicdomainsoftware.org). We had this javascript stuff working, but it only worked for IE. You can see a working version here: http://www.publicpen.com/designer/mcControlPanel.php username: designer password: designer123 However, I've tried to rewrite this so it would work in all browsers,
14
4972
by: Kevin | last post by:
A couple of easy questions here hopefully. I've been working on two different database projects which make use of multiple forms. 1. Where's the best/recommended placement for command buttons for things like delete, save, edit, cancel buttons - in the footer, or on the form detail section? 2. If in the footer, how do you add them to the tab order?
3
3767
by: Morten Snedker | last post by:
If I have a number of random applications open, move the mouse cursor to a given position and do a click, the application gets the focus. That is what this simple code should illustrate: Dim pt As Point Dim wnd As IntPtr Const WM_LBUTTONUP = &H202 '//LButton up Const WM_LBUTTONDOWN = &H201 '//LButton down
5
6762
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created link buttons to stay wired up to their click events. I have what is basically a simply survey question generation page. The page first displays a few static fields and a dropdownlist of various options for the user to select. When the user...
8
1717
by: Rabel | last post by:
I am new to asp and I am having a little trouble with the Request.form option. What I want to do is I have a dropdown box. <select name="selecter" class="text" id="selecter"> <option value="page1.htm" selected>Page 1</option> <option value="page2.htm">Page 2</option> <option value="page3.htm">Page 3</option> </select> and I want to use a button that then will take you to the page you
0
1681
by: Ironr4ge | last post by:
Hi everyone, By the rate its going it want be long till I start growing gray hair... but anyway.. to come to the point... I am trying to open the form "Languages" with a diffrent record source to the "Contacts" form where I conducted the search or filter... . I was wondering whether there was a simple vba code to select ONLY ALL FILTERED records of my first form or the "Contacts"
2
3219
by: bhipwell via AccessMonster.com | last post by:
I need to put a button that allows the user to move to the next record. On the form, I have a list of employees that are filtered by the company they work for. Obviously, if I use the simple Gotorecord command, it will pull up the next record regardless of what company that employee works for. So... 1) I need the button to take the user to the next record where the company (field is CompanyID) matches the company on the form.
5
13379
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL http://mghospedagem.com/images/controlpanel.jpg instead of http://mghospedagem.comhttp://mghospedagem.com/images/controlpanel.jpg As u see, there's the website URL before the image URL.
0
9602
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
10237
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
10071
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...
1
10017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9882
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
6690
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
5467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3987
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
3
2832
bsmnconsultancy
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...

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.