473,396 Members | 2,154 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.

Error msg on form with closing

Hello friends, Can any one help on my issue

I got an error msg on form with closing. I have a main form (SalesReturnOrDamaged) and subform (SalesReturnOrDamagedSubform).

So if empty form close then i need to without save the record. So in this case i have used a VBA code on Close Command button as per shown in Code Tag. But that is not working and shown an error msg as per screenshot. Can you please replay how to give a VBA code for empty form close without save the record?

I have attached the dB and screen shot with explanation.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Close_Click()
  2. On Error GoTo Err_Close_Click
  3.  
  4. If Forms![SalesReturnOrDamaged]![SalesReturnOrDamagedSubform].Form![ItemCode].Value = "" Then
  5.    Forms![SalesReturnOrDamaged]![SalesReturnOrDamagedSubform].Form![Product].Value = ""
  6.    Forms![SalesReturnOrDamaged]![SalesReturnOrDamagedSubform].Form![MRP].Value = 0 Or ""
  7.    Forms![SalesReturnOrDamaged]![SalesReturnOrDamagedSubform].Form![Qty].Value = 0 Or ""
  8. Beep
  9. If MsgBox("Do you want to delete this Return Record? Because Subform Product details are not updated properly.", vbYesNo, "Delete Confirmation") = vbYes Then
  10.    DoCmd.RunCommand acCmdDeleteRecord
  11. Else
  12.    GoTo Exit_Close_Click
  13. End If
  14. End If
  15.  
  16. DoCmd.Close
  17. Exit_Close_Click:
  18. Exit Sub
  19. Err_Close_Click:
  20. MsgBox Err.Description
  21. Resume Exit_Close_Click
  22.  
  23. End Sub
Attached Images
File Type: jpg Error screenshottt.jpg (48.6 KB, 154 views)
Attached Files
File Type: zip ERROR with form close.zip (235.7 KB, 72 views)
Nov 12 '14 #1
2 1056
twinnyfo
3,653 Expert Mod 2GB
One way to do this is to have unbound controls, and if the user wants to save the record, then it appends the data to the table. Remember, when you have bound controls on a Form, any time any text box is updated, the data is "saved".

You could also try adding
Expand|Select|Wrap|Line Numbers
  1. Me.Undo
after the Beep, which should get rid of any changes to that record.
Nov 12 '14 #2
Actually i don't have better knowledge on VBA and creating unbound controls i think it’s mostly depending on coding. So i can design the forms directly from tables. So there is any way to work with above VBA code type?? I think just edit the above on the screen code can you please help how to change the above code?
Nov 12 '14 #3

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

Similar topics

2
by: khan | last post by:
Hi guys, I have a form called frminvoice, On this form I have a button to ptint report or invoice where report will get invoice number from !. Now I want when I click print invoice button, it...
2
by: news.microsoft.com | last post by:
Hi there, I was just curious if anyone knew how to create a .Net event that is similar to Form.Closing event, where in I can set the Cancel property of the event argument to true and it will...
8
by: Mickey Swanson | last post by:
Is there any way to determing why a form is closing? As in if the user cliced the x button or if a system shutdown has started. thanks for any help Mickey Swanson
2
by: Michael C | last post by:
Hi all, Receiving an error when closing an application that contains the AxWebBrowser component, whenever I close the app: ".NET-BroadcastEventWindow.1.0.5000.0.4: myApplication.exe -...
9
by: Ron | last post by:
my application is throwing an exception error when closing if I run a procedure in the app. I can't even trap the error with try/catch ex As Exception. Is there a way to completely shut down the...
6
by: **Developer** | last post by:
I've been looking but can't find out how in a form Closing event to know if the closing is because the form's "X" had been clicked or the main form's "X" was clicked. That is, I need to know if...
19
by: zacks | last post by:
I have a .NET 2.0 MDI application where the child form has a Tab Control. Each of the Tab in the Tab Control has a Validating event to handle what it should do when the user changes tabs. But...
19
by: rbrowning1958 | last post by:
Hello, I am confused by dispose etc. and hope someone can set me right. 1. The Dispose(Bool) the IDE generates for a form has nothing to do with IDisposable, right? 2. So when is this called?...
1
by: Aleksey Timonin | last post by:
Hi guys, I show my Form in dialog mode. So I have "Ok" button on it with DialogResult = Ok. What is the right way and how can I abort form closing from the button click event. Thanks a lot...
15
Seth Schrock
by: Seth Schrock | last post by:
I'm using Access Runtime 2010 for my users to use my database. frmHome is the name of the form that opens automatically. If I have frmLoans and frmHome open and click the X to close the program, I...
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
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
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,...
0
isladogs
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...

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.