473,403 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Duplication of append/requery results in subform

I have created a questionnaire that contains the participant's information on the main form, and the questions/answers on the subform. A button (on click event)populates all questions, each with a dropped down box for a selected answer. Since this form will be updated by a data entry user, how can I prevent the code from running multiple times if the button is clicked more than once. Currently, if I click the button once, the procedure works fine. If I click again, the same data is appended to the subform. I think I need to use some type of If/Then statement, but unsure how, since I am a newbie of VB. Can anyone help in laymen's terms????
Dec 15 '15 #1
3 885
BHo15
143 128KB
I'm not completely sure I understand your set-up, but here is a stab.

If the button is on your main form, and the populated answers are populated on the sub form, you could use something like this...

Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click
  2.  
  3. If Forms!MainFormName!SubFormName.Answerfield<>"" Then
    Exit Sub
    Else
    Perform the code you have written
    End If
  4.  
  5. End Sub

And by the way... Welcome to Bytes!
Dec 15 '15 #2
Thank you for your quick response, unfortunately it did not work. I received a run time error. Instead I used this:

If Me.sfrmRespAnswr.Form.RecordsetClone.RecordCount = 25 Then

Exit Sub

Again thank you so much!
Dec 15 '15 #3
BHo15
143 128KB
Glad you figured it out. Congrats!
Dec 16 '15 #4

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

Similar topics

2
by: F. Michael Miller | last post by:
I need to requery a subform from a third form and can't seem to get it to work. frmForm1 has frmAddress as a subform. The button cmdReviseAddress opens the form frmUpdateAddress where all of my...
3
by: ken | last post by:
Hi, I have a main form with a text box and a filter button. I also have a subform in the main form. When I make an entry into the filter text box and click the filter button, I change the query...
3
by: 4004 | last post by:
I have a frmSet (I am a teacher) which has a frmSetQuestions subform, which shows a filtered set of questions. I have a lboTopic which I use in the criteria of the subform recordset to filter...
1
by: BartonConstruction | last post by:
Greetings all, I have a main form (frmClients) with two subforms (subVisits) (subAccount). I got the subforms to reflect what the main form is showing by linking master and child fields (I...
2
by: cmichaud | last post by:
Previously i had a combo box where i could select a name and then click a button and a subform on that form would requery and give me the information i wanted. However, i have now changed the...
1
by: kimj.dk | last post by:
Hi, I have a form with a subform where the subform uses the value from a combo box on the main form as a query criteria. I don't want the subform to update or get data before the user has selected...
1
by: Parasyke | last post by:
I have a subform within a tabpage that will requery/refresh (?) if I press F9 and it will update the data in the subform, but I have tried various combinations of Me!SubformName.requery...
4
by: Robert | last post by:
Hello. I have a form with 2 subforms on it, subform1 and subform2. Is there some way to requery subform2 from an after update event on one of the fields on subform1? What would the syntax of...
2
by: mslagle1 | last post by:
Hi all, I am trying to requery a subform "frmOpenWorkOrders" when a value list "status" on my main form "frmWorkOrderMain" is changed. If I change "status" then click on "frmOpenWorkOrders" and...
6
by: ConfusedMay | last post by:
Hi, I'm using access 2003. I have a textbox called txtdate on the main form and when I click this textbox I have a calendar pop up and users can select which date they want it to be appear on this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
agi2029
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,...

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.