Stop Code Running If Fields Blank

Nov 29, 2006

Ok - really need some help here. I have searched and searched but i think my problem is slightly different to the ones i am finding.

Basically i have a form and i want to force users to fill in one out of 4 tick boxes. If none of them are ticked when they press the close button i want the form to stay open and a message box come up.

I can get the message box part to work but the form still closes down.

The reason for this is that when the form closes it goes to another form that is linked to it by a unique ID number. This works by the following code.

Private Sub BTN_INVIS_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm closure"

stLinkCriteria = "[issue ID]=" & Me![Issue ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_BTN_INVIS_Click:
Exit Sub

Err_BTN_INVIS_Click:
MsgBox Err.Description
Resume Exit_BTN_INVIS_Click

End Sub

What i have tried to do is insert a piece of code into the above to generate the message box so it now looks as follows:

Private Sub BTN_INVIS_Click()

If [Transport_Delivery_issue_] = False And [Process_issue_] = False And [Design_issue_] = False And [Supplier_issue_] = False Then

MsgBox "You must complete the liability box before you can close this issue"

Cancel = True

[Design_issue_].SetFocus

End If

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm closure"

stLinkCriteria = "[issue ID]=" & Me![Issue ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_BTN_INVIS_Click:
Exit Sub

Err_BTN_INVIS_Click:
MsgBox Err.Description
Resume Exit_BTN_INVIS_Click

End Sub

This code checks the boxes and generates the message box if none are ticked - that works great. However it doesnt stop the second part of the code (the move to the next form) from executing if the boxes arent ticked.

Would really appreciate it if someone could help me - i'm fairly new to coding so the whole database is a bit cobbled together (mostly with help from this forum!).

View Replies


ADVERTISEMENT

Cannot Stop Blank Forms!!

Dec 6, 2006

Hi guys,

I have created a form based on a query that prompts the user to enter a persons name. Once entered, the persons data appears on the form and some other related data appears in a subform. However, I have found a problem that occurs when a name is entered that doesnt exist on the database... the form opens completely blank!! even text and graphics disappear!

Is there a way of stopping this from happening??

Thanks, James

View 2 Replies View Related

Queries :: Stop Query From Running Automatically

Jan 14, 2014

I have a form with tab set one tab called "Enter Receipt" and another that houses 2 queries called "Reconcile". My issue is when I open that form, I have an On Current Macro to go to NEW record for my Enter Receipt, but I am getting a delay while the query status bar runs the other queries. I was hoping not to have those ran until i enter the parameters and hit the run button on that "reconcile tab".

Everything else works, i just need the queries to keep from running when i load the form. my queries i moved from EDITED to NO LOCKS thinking the On Current new record may affected them, not change in delay.

View 3 Replies View Related

Modules & VBA :: How To Stop Running Procedure Or Function

Jul 13, 2014

I need to stop already ran procedure or function with vba code . So I use END command ans everything stops.. in some cases that is useful, but some times need I to do something else after I use END command, but after END everything stops...

LIKE THIS :

SUB ()
END
ME.CTL.SETFOCUS
'OR
CALL function
EXIT SUB

View 5 Replies View Related

Stop Form From Opening When Query Is Blank

Dec 16, 2011

I have a button that opens a form based on a query, the query is filtered based on an input field. This works great except when the user typos what they put into the input field. Since the query pulls no records it just opens a blank form. I want it to not open the form and instead open a message box telling the user the data they entered is not valid and to try again.

View 1 Replies View Related

Modules & VBA :: Can Manually Stop Auto-Exec Macro From Running By Holding Down Shift Button

Dec 22, 2014

I can manually stop the AutoExec macro from running by holding down the shift button - how do you do it by VBA? I'm opening the db from Excel, and I don't want the Switchboard to display ...

View 1 Replies View Related

General :: VBA Access Code EOF Does Not Stop / When Records Are Over

Jul 3, 2013

I have an excel file, and am trying to import it, and once when I have imported it, am checking for a condition with While Not rs.EOF, it works fine for the purpose of looping, but it does not stop when the records are over., it is additionaly printing 19 null statements, where I beleive it, should not be.

View 9 Replies View Related

Disabled Breakpoint Continues To Stop Code

Aug 15, 2014

I had to put a breakpoint into my VBA code in one of my apps to debug a problem I was having and inspect the variable values. All was well until I finished the debugging process and tried to eliminate my breakpoints. However, the next time I ran the application, the code stopped as if one of the breakpoints was still active. I closed the application and reopened it (even rebooted the computer) and the code continues to stop in the same spot in the program. The only thing I can think of to do is to create a new empty Access database and import all the objects from the old one. I'm thinking the database must be corrupt and this is all I know to try.

View 3 Replies View Related

Forms :: How To Stop OpenArg Code When Field Is Already Populated

Sep 4, 2013

I have an order form that auto-populates details from the customer table into adderss and contact controls. But I don't want it to auto-populate when the underlying order table already has data in the related fields. Here is the code I use on Load form event...

======
Private Sub Form_Load()
'Use this version if the ID is a number
Dim x As Variant
Dim strControl As String
Dim lngID As Long
'If parameters exist, use them
If Len(Me.OpenArgs) > 0 Then

[Code] ....

View 2 Replies View Related

Erorr When Running Code

Apr 11, 2005

I am getting an error 'Run time error 2001, You canceled the previous Operation'. I don't know where I am makin a mistake in this code. I hope you guys will figure it out.

Private Sub Form_Load()

'On Load of the switchboard check Jobs table for any uncompleted jobs

Dim intStore As Integer

'Count of uncomplete jobs that are past the Expected Completion Date
intStore = DCount("[ID]", "[Sheet2]", "[Follow up date] <=Now() AND [Appointment Reminder] =0")

'If count of uncomplete jobs is zero display switchboard
'Else display message box detailing amount of jobs
'and give the user the option as to whether to view these or not.
If intStore = 0 Then
Exit Sub
Else
If MsgBox("There are " & intStore & " uncompleted jobs" & _
vbCrLf & vbCrLf & "Would you like to see these now?", _
vbYesNo, "You Have Uncomplete Jobs...") = vbYes Then
DoCmd.Minimize
DoCmd.OpenForm "Reminder", acNormal
Else
Exit Sub
End If
End If
End Sub

View 4 Replies View Related

Error Running Code

Sep 29, 2006

Hi,
I get this error when trying to rung a piece of code:
The expression On Load you entered as the event property setting produced the following error: Member already exists in an object module from which this object module derives.

I have the EXACT same code working on other forms using different fields and I just can't figure out why this particular one isn't working, it's driving me nuts!
My code is this:
Private Sub Form_Load()
Dim strReason As String

strReason2 = Nz(Ref3Poor_Reason, " ")

Select Case strReason3
Case "Not Known", "Unwilling to Give"
Poor1NavRef3.Visible = False
Poor2NavRef3.Visible = True

Case Else
Poor2NavRef3.Visible = False
Poor1NavRef3.Visible = True

End Select

Dim Ref3PoorCheck As Boolean
Ref3PoorCheck = Ref3Poor_Reference

Select Case Ref3PoorCheck

Case "True"
Ref3Poor_Reason.Visible = True

Case "False"
Ref3Poor_Reason.Visible = False

End Select

End Sub

Can anybody tell me where I'm going wrong please?
Thanks,
Dan

View 1 Replies View Related

Running Code When Data Changes In A Table

Oct 25, 2005

Hi

Ive made a booking system in Access and need to convert it so it can handle multiple users on a network. The problem i have is that when someone selects a block of time on one computer i need the other systems to lock out those blocks on their screens. I have a table which records each user's activities so i could always use the On Counter event on the form to repeatedly check if there is any blocks to be locked out according to data in that table. The obvious problem with this is the huge overhead.

Is there any other way round this? or is there any way of detecting changes to data in a table so that i can run code to lock out the blocks only when theres a change?

Any help or suggestions much appreciated! :)

View 1 Replies View Related

Modules & VBA :: Code To Find Out If Another Program Is Running?

May 19, 2014

I found code at this website that is supposed to determine if a specific program is running on your computer. I have a couple questions about the code here. One, when I run it just the way it is and call it in the immediate window with the ?fIsAppRunning("word") command, it tells me "True" whether I have Microsoft Word open or not.

My other question is this: After the code is working properly, how can I add new programs to it? There are two programs the end user might need open to complete a process. One is called Extra and one is called tn3270 (this is how they show up in the Processes tab of the Task Manager). I think in order to add them to this code, I need to know a "class" to associate with them.

View 1 Replies View Related

Forms :: Running Code On Individual Records

Mar 20, 2015

So in my database i'm creating a live form that will open up a list of patients and when they are seen. one of the bits is a button that before they arrive says "Not Arrived" and after they arrive it says "Arrived". The code works fine:

Code:
Private Sub Command68_Click()
Dim C1 As String
Dim C2 As String

[code]...

The problem is after clicking the button on any of the records, it changes the text on all records, to wit: I tried to attach images or links to images, but my post-count is too low. The before-click screenshot is /3QnBkgG on imgur. The after-click screenshot is 9VZWzzp on the same site.

Bear in mind I've only clicked the button (it's white, so it doesn't look like a button) on the top record.The form is set to continuous forms, not sure if that has anything to do with it.how I can get the code to run on individual records, rather than applying the first-record's results across all records?

View 12 Replies View Related

Why Format Event Code Running On First Record Only

Aug 28, 2013

I have a report with several sub reports that run and fill a table conditionally. The third sub report displays the records from this table. It works perfectly.

If I print a batch of records, it also works perfectly - but only for the first record. Previously, I had another report with several sub reports where the visibility of objects were controlled - this worked fine in a batch. Every subreport had the correct visibility settings.

In this case, I have a similar design, but instead of setting visibility on the various subreports, I am filling a table based on data in the subreport. As stated it works great for the first one in the group, or any single print.

View 4 Replies View Related

How To Stop A Form From Closing If Some Essential Fields Are Not Populated

Mar 31, 2006

I tried putting the following code in the form unload procedure, but although it does generate the correct message, it doesnt stop the form from closing.

Private Sub Form_Unload(Cancel As Integer)
If [Starttime] > 0 And [Admin_time] = 0 Then
response = MsgBox("Please click on the stop button to stop the clock")
Exit Sub
End If
end sub

If the above condition holds, I want the user to click on the stop button before they close down the form. I'm guessing that the form is already commited to closing before the unload event? :o

View 5 Replies View Related

Forms :: Create A Message Box To Flash On Screen To Tell User That Update Code Is Running

Mar 6, 2014

I need to create a message box or a form or something to flash on the screen to tell the user that a piece of "Update" code is running. the update code will be updated reports from marketing returns, but the 3 branches who use the information are separate so I am creating an update form to download and update the table.

The code for the update is already working, but can take a while, so I thought a message or splash screen would be useful as the update runs on start up.

It would have another use, I have a report which is made mainly of calculated fields on an onPrint event and also takes a while to work it out, so a similar screen would be more useful than my current spinning circle and blank screen.

View 1 Replies View Related

Reports :: Running Sum Fields

Jul 4, 2013

I have a report about bowlers & series. I am attempting to do a running sum on each bowler's series & games bowled each week, so I can get a new composite average each week.The data looks good until the 2nd to last row of data. The running sum on series & games bowled for every bowler is blank even though I have a series that week for all bowlers. And the averages for that week show a 0. The very last row of data for all bowlers is fine and correct.

View 3 Replies View Related

Blank Fields

Jan 19, 2006

Hi - I have what maybe a relatively easy problem to solve.

I have a list of locations each with a unique id. I also have another table with location details in it. There is a relationship setup between the two tables. However in the first table I have some locations that do not have a match in the second table. Therefore that field is left blank. When create a query to show information from the two tables, any records that have a blank location match field do not get shown in the output. Is there anyway to display records with blank fields?

Thanks

Nick

View 4 Replies View Related

Blank Out Certain Fields

Mar 21, 2006

In an Input form, how can I blank out certain fields such that the field data is shown, but grayed out, and other fields are shown normally?

View 1 Replies View Related

Forms :: How To Use Data On A Form When Running Code Before Closing The Form

Feb 4, 2014

I have a bound form with a few fields. I would like to run a sub after some of these fields are modified, but not others. I would like it to run only once, after user finishes his work on the form.

When using the Unload event - the form on the form is not there anymore (or did I get something wrong?).

Is there a way to trap Data on form just before the form closes?

View 4 Replies View Related

Add Together A Running Total On Input Fields In A Form?

Aug 28, 2005

Hello, I have 4 input field boxes in a form: "basic hours", "overtime hours", "holiday hours" and "total hours" i would like it so that when the user enters number(s) into the other field(s) the total field will calculate (add togther the other fields). So for example if the user puts "10" in the "basic hours" input field and "5" in the overtime hours" field then the "toal field" will display the number "15". i would like it so that the "total hours" field calculates the total progressively after each number in the other fields is input (ie a running total is displayed). The user will always fill in basic hours but 1 or more of the other fields can be left blank. I think i need to do some VB on the after update procedure for each field entry but not sure what the code is?, any help would be brilliant.

View 7 Replies View Related

Blank Fields Sort

Jul 29, 2005

Hi,

Is there a way to get blank fields to sort to the bottom rather than the top when sorting alphabetically in access?

TIA!

View 2 Replies View Related

Tables With Blank Fields

Oct 26, 2004

I am a firefighter who has been tasked with creating a database to track repairs and inventory on breathing apparatus(SCBA). There are several(5) related pieces of equipment that I think should go on the same table. Three of these will have nearly identical fields. The other two will have additional field specific to them. Should I create one table including all five pieces and just leave the extras fields blank or is there a better way.
Thanks.

Mike

View 2 Replies View Related

Blank Fields In Query.

Oct 28, 2005

Hello, I have a table (Projects) with original projects and amended projects. All information regarding each project is inputted in the fields for original projects. Only limited fields are inputted in amended projects;new loan amounts or a new closing date may arise infrequently for amended projects. When there is a new closing date for an amended project, and it becomes part of a query all other fields are blank for that record, How do I populate the original project data into the blank fields of an amended project. I frequently have to create queries based on the fiscal year of closingdate field and I need to know the commitmentdate (field) and other dates that are in the original projects records. I hope this is not confusing thanks in advance. :confused:

View 1 Replies View Related

Hide Blank Fields

Nov 4, 2006

Hi Friends,

Sounds Impossible But i believe there must be a genius out there to solve this

I was wondering if there is a way to stop displaying fields on a form which contain spaces or blank values. I m using a query that takes data from a table named School

I have a table which have 5 fields. lets say: Field1, Field2, Field3, Field4, Field5

My fields from 1 to 3 have data but field4 and field5 do not have a value in it. What i wish to achieve is to show only those fields which have a value in it. Blank or field with spaces must not be displayed. Is It Possible.

Regards,


Darno

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved