473,396 Members | 2,158 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,396 software developers and data experts.

Prevent Close Or Update Of Form Or SubForm

135 100+
Heya...

Thanks in advance if you can help... or at least understand my gibberish.

I have 2 tables, let's call them tblBacT and tblBacTData, they are related through the auto number primary key "entryId" in tbleBacT. I have created a form (frmBacT) and sub form (subfrmBacTData) with the sub from in columnar view. Kiddie stuff right? My problem is: I don't want the user to be able to enter data in the sub form and then exit or move on to another record in main form frmBacT. This leaves me with an unrelated record in my tblBacTData. I have spent countless hours trying to either; prevent the sub form from being active until the main form is correctly filled, delete or undo on exit or before update if the sub form has data but the main form is empty, or require fields. The problem with requiring a field, say at the table level, is that there can be any number of combinations to enter. e.g. Of the 8 fields the user may use only 3 one time and maybe 5 diff the next. If this makes sense...HELP

I'm a newb at VB, trying to learn on my own (ouch)... been just googling and piecing in what I can for diff needs.

Thanks
Dec 14 '07 #1
3 3188
NeoPa
32,556 Expert Mod 16PB
Have you tried disabling the subform by default, and only enabling it when the correct conditions are met?
Clearly, whenever the conditions are no longer met, you would need to disable it again.
Dec 14 '07 #2
MyWaterloo
135 100+
Have you tried disabling the subform by default, and only enabling it when the correct conditions are met?
Clearly, whenever the conditions are no longer met, you would need to disable it again.
Yes...that works...kind of.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.      If Form.NewRecord = True Then
  3.           Me.BacTData_Subform.Form.AllowAdditions = False
  4.      End If
  5. End Sub
  6.  
  7. Private Sub Form_BeforeUpdate(Cancel As Integer)
  8.      Me.BacTData_Subform.Form.AllowAdditions = True 
  9. End Sub
SO after I update on the main form I can enter info into the sub form. I still need to delete/prevent update of the main form if nothing is entered into the sub. The main form and sub form records create one composite real world record. I don't want the user to do just part of the record, exit the form, and have part of a "record" floating about.

Thanks for responding.
Dec 14 '07 #3
NeoPa
32,556 Expert Mod 16PB
I guess you could put your code to handle that (cancel update or move you back to the unfinished record) in the OnCurrent event procedure.
Dec 14 '07 #4

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

Similar topics

9
by: Catherine Jo Morgan | last post by:
Can I set it up so that a certain combination of fields can't contain the same entries, on another record? e.g. a combination of FirstName/LastName/address? Or FirstName/LastName/phone? Or...
1
by: Aravind | last post by:
Hi folks. I have a form that has a form header and form footer, which has a few command buttons. When I open the form, I have to scroll the form from left to right to view my data. The thing is,...
4
by: deko | last post by:
I have a pop-up form in which user-defined parameters are entered. The parameters are entered into a subform datasheet which is bound to a table. I need to check the product of two parameters to...
12
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...
8
by: Smartin | last post by:
I have a form in Access97 which facilitates a query against a production Access database. Users will enter some search terms and see a datasheet view of the results in a subform. The prod table is...
4
by: tlyczko | last post by:
I have been looking on the NGs and I found this code to show if a subform has no records. I have this code in the MAIN form OnClose event: Private Sub btnClose_Click() '4/16/06 new code that...
4
by: Ryan | last post by:
I've got a little bit of code that runs when you enter data in a datasheet view (which is a subform of the form you are in) if rst!DateReceived >= 30 Then Forms!DisposalRecords.Label90.Caption =...
2
by: Ron | last post by:
Hi All, Okay, I've got a frmOrders with a subform of sfrmDetails. A frmClient has all the client info, plus a subform of sfrmDefaults that has the client's normal ordering defaults (like set...
3
by: Kelii | last post by:
I've been beating my head against this problem for the last several days, and I haven't found a decent solution yet. So I'm turning to the group for some moral support or better yet some answers. ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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...
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.