Events Not Triggering
Jun 23, 2006
Access front end, SQL Server backend.
----
I have a continuous subform (part of a tab control on a main form) whose name and sourceobject are both "sbfCannulae". There are about 10 fields on the subform, and all are bound to fields in a table. The primary key of this table must be generated by combining two other fields, which must happen just before the record is saved. (I know calculated data should not usually be saved in tables, but trust me. In this case it is necessary.)
Right now the user COULD enter data into the primary key-bound textbox, but since the user is me, I make sure not to do that.
When I enter data into all fields except the primary key, I get an error because the primary key cannot contains nulls...of course.
I use the following code to tell me when an event has been triggered.
Code associated with sbfCannulae:
Option Compare Database
Private Sub Form_Activate()
MsgBox "cann activate"
End Sub
Private Sub Form_BeforeInsert(Cancel As Integer)
MsgBox "cann before insert"
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
MsgBox "cann before update"
End Sub
Private Sub Form_Current()
MsgBox "cann current"
End Sub
Private Sub Form_Dirty(Cancel As Integer)
MsgBox "cann dirty"
End Sub
When I enter data into a new record, the Dirty event is triggered, but I cannot for the life of me figure out how to trigger any of the other events. No combination of values and nulls in any fields, clicking in other tabs, clicking to other records, or using the navigation buttons will ever trigger any events but Dirty.
The only msgbox I ever get is the one giving delivering the SQL error about the primary keys not taking null values.
What am I doing wrong?
-Matt
View Replies
ADVERTISEMENT
Dec 30, 2014
I have a form which has been in use for some time now, and works extremely well for all users; as part of a recent update to that form, I added a few events to various controls; most of them are message box prompts to remind the user to do something, but one is automatic entry of text into a memo field when another field is updated, and it is really this last one that is causing an issue.
There is a command button on the form which has an embedded macro, created using the wizard - it is probably the last, or one of the last few buttons that have a macro as opposed to VBA.
Essentially, when this button is clicked, I would like a duplicate of the current record to be made (thus giving it an Autonumber ID of its own), and if possible I would like this to be done without triggering any of the after update events on the form. Is there a way to disable these events and copy a record in its entirety, re-enabling the events at the end?
View 2 Replies
View Related
Aug 16, 2005
Hello one and all
It may seem a rather simple question, though it continues to confound me -and I have searched to no avail :D
How do you trigger an event depending on what button is pressed on a msgbox?
For example, using a vbYesNo msgbox on a form, how can I assign events to either the Yes or the No option? Say, if "Yes" is clicked the focus would be set to a control on the form, and if "No" is clicked access would close down.
Any ideas?
I've currently got on the on click event of a command button (the bit in italics is fine, the bit in bold is not working!):-
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click
Dim stDocName As String
MsgBox "Please select where you wish to save the exported file", vbOKOnly, "Save To Location"
stDocName = Month.Value
DoCmd.OutputTo acTable, stDocName, acFormatXLS
MsgBox "Do you want to select another History Extract?", vbYesNo, "Do you wish to continue?"
If intresponse = vbNo Then
DoCmd.Close
Else
Month.SetFocus
End If
Exit_Command3_Click:
Exit Sub
Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click
End Sub
But whether Yes or No is selected, the focus returns to the current form.
Cheers for any ideas
View 3 Replies
View Related
Mar 4, 2005
I have a form in my database that opens by default. I want to trigger a yes/no (yes would run a query, no would end) popup based on the value of a field in a table or query (i.e. if "now" is fifteen days past date in the table/query).
Any help would be most appreciated.
-Eric
View 4 Replies
View Related
Jul 14, 2005
As above, I've noticed that it will only trigger if there are no textboxes on the form with a higher tab index than the control the keyascii is set for. Any ideas why, or what I'm doing wrong?
I've found this a lot and never bothered trying to find a solution till now. :p
Gareth
View 1 Replies
View Related
Jun 25, 2015
I have a combo box in a form which simply pulls a text field from a single table - approximately 100 values to choose from. On the After Update Event, there is a basic "If null this, else that" VBA which just hides a subform if the value is null. This works fine, except there are a handful of values (I've found at least 6) that when chosen, trigger the NULL portion of the code! All the values are very similar, so I don't know what the problem is - for example, the value "D-11" works, but neither "D-10" nor "D-12" does.
View 11 Replies
View Related
Nov 19, 2012
i have list box which lists all active records. raw source is based from Main Query which lists all active records from current user. on click even of list box i have macro that goes on record selected in list box, which is working fine.on current event of main form function is called. Main Query order by id Desc, list box order by is Asc problem is when i click on last field in List Box which takes me to record, On Current event does not trigger on main form. if i use Record Selector on main form to go to that same record,On Current triggers.
View 2 Replies
View Related
Jul 28, 2015
we have gotten in to a routine of copying, pasting and bastardizing old databases instead of creating new ones from scratch - and we've had a problem recently where we've started off with one master database back in 2011, which has then been the base for practically every single major DB we've created ever since.So this month we've copied and pasted (again) and started adding new features to what's already there, and the thing has corrupted. I've copied and pasted the same version three times and added all the new bits, and the same thing has happened every time.
So this time I've copied and pasted and tried my best to clean up, get rid of the dead weight and (where necessary) create completely new objects, split into FE and BE versions etc, and I've reduced the overall weight of the DB by about 50%.Due to time constraints I now need to crack on and get this thing working again and, for the most part, it does - but now I'm having trouble carrying the filter over from the OnClick Event of a form button to the next form it's opening.
We're using the DB to record attendees at an Event we're running later in the year. This is the code that I'm running from the OnClick Event of the button on Form1:
Code:
Private Sub btnBkg_Click()
On Error GoTo Err_btnBkg_Click
Dim stDocName, vFilt As String
Dim vBkgRef As Long
Dim vContactID As Long
[code]....
You can see I've tried to use vFilt instead of the actual code for frmBooking's Where Condition, but for some reason it does not carry over to the form whichever way I try - when I open the immediate window and type ?vFilt it returns a blank entry. Not sure how to show the 'Where Condition' in the Immediate Window?Before Update, Open and Activate of frmBooking, but I'm hoping that the problem lies with what I've posted up here, as I don't want to get into posting the frmBooking code...
It may be worth noting that the button resides in the Header of a continuous form, with conditional formatting that changes the button caption depending on whether there is a value in the BkgRef text box of the record that has the focus.
View 3 Replies
View Related
Aug 17, 2006
Hi,
I am wondering whether it is possible to trigger the run of a macro when a form window is closed using the close button in the top right of a standard window?
If not, then is it possible to display a form in a window without the minimize, restore and close buttons?
I am currently using a setup whereby I have a button to close a form, and when clicked a macro is executed. However, the user could just as easily close the form using the close button of the window and the updates would not be performed.
Thanks in advance
Turbojohn
View 2 Replies
View Related
May 23, 2014
I have the below VBA in a from for it to filter the records below based on the criteria:
Private Sub Search_Click()
Dim strWhere As String
strWhere = IIf(Len(Me.AssignedTo & "") <> 0, "([AssignedTo] Like ""*" & Me.AssignedTo & "*"") AND", "") & _
IIf(Len(Me.OpenedBy & "") <> 0, "([OpenedBy] Like ""*" & Me.OpenedBy & "*"") AND", "") & _
IIf(Len(Me.Status & "") <> 0, "([Status] Like ""*" & Me.Status & "*"") AND", "") & _
[Code] ....
When I click the search button nothing happens, is there something wrong with my code??
View 4 Replies
View Related
Nov 25, 2014
I will have a PC and a number of scanners in a production line. I will need at least 15-20 scanners and would like to plan for more if needed. When an operator clicks on a button I would like to have each of the scanners triggered and return the value. They can be done in turn or all at once (preferred for speed). I need to know which value came from each scanner. I would then compare the barcode read at each station versus what is supposed to be at that station and either pass or fail.
View 2 Replies
View Related
Aug 18, 2014
I have a main form that holds a tab control with a number of sub forms. One of these subforms has a pop up form for adding new records to it. After closing this pop up form I would like to initate code on the sub form where the new record now will appear. One of the things I like to do is simply to set focus to the record the user just added.
My problem is that I cannot seem to get any event to trigger in this setting (bben trying more or less all). If I understand things right the fact that I am using a pop up form and the fact that I am using a tab control both seem to interfer with the Activate event and making it passive.
How I can trigger code on the sub form (after closing the "Add New" pop up form)?
View 6 Replies
View Related
Jul 10, 2005
Here is what I want to do:
I'm organising 15 training events, for 60 participants. These 15 training events fall in three themes: running, swimming, cycling. So there are 5 training events held on running, 5 on swimming, 5 on cycling. Each has on average 4 participants, but in reality, some have 6, some 2.
Everybody has to attend each of the three themes, so three of the 15 events.
I have a table called "events". each record contains data on a certain event (place, date, speaker, participants,...)
I have a table of 60 participants, with: their names, their age
Per event, I want to indicate who is participating, with a combobox. Now, the number of participants per event is not limited, so it could be 5 or 30.
Also, it could be nice if the combobox content is limited to the people that haven't been selected yet. So if John Doe is already taking the swimming training in event Swimming1, if I pull down the list of participants in event Swimming2, I do not want to see John Doe's name there.
Also, I want to calculate the average age of all the participants of a certain event.
I want to print out two reports:
1) per training event, an overview
2) per participant, an overview of all the events he has inscribed to
How do I go about this?
Currently I am using 30 comboboxes, and 30 fields in the table "events", called participant1, participant2, participant3,..., participant30
But it is becoming messy, and when I ask for a report per participant, he only gives me the details for the people in participant1.
View 9 Replies
View Related
Oct 7, 2005
Right this is a fundamental issue for me here and I cant get my head around the problem!!!
The database I am working on is a database which records the training courses (run by the NHS) which staff at GP surgeries in our area have attended and acts as a booking system for them.
So we have the obvious tables - one for courses (including the name, cost, etc) and then one for course dates (linked by courseID) and one called training_record which contains who went to what when.
It seems simple but it has come to my attention that for example, "Course A" may in fact take place over 2 days, which could be a week apart. The surgeries are billed in one invoice, i.e. Course A would be £100 for 2 days.
How would you recommend I have this data? I can see all sorts of confusion arising... :(
The only way I have thus far thought would be to put each one in like:
course name: cost date
Course A: day 1 £100 - 29/10/2005
Course A: day 2 n/a - 6/10/2005
Course A: day 1 £100 - 01/11/2005
Course A: day 2 n/a - 08/11/2005
However this seems long winded as some courses may be a few days long and this means adding each person to multiple ones!!!!
Any assistance with getting my head around this would be ace! :)
View 1 Replies
View Related
Feb 15, 2006
Is just me, or are all of the events on tab control tabs disabled?
View 3 Replies
View Related
Sep 10, 2006
Dear friends
I request your comments please...
I have a form with bound and unbound fields and have linked the [Event Procedure] on these fields base on there respective action.
Now when I open or click a particular field with the event procedure, the procedure is names are like -
Private Sub Rate_Exit(Cancel As Integer) or
Private Sub Quantity_Exit(Cancel As Integer)
but others events are name like Private Sub Quantity_Enter() simple. Why is that ms access (Cancel As Integer) uses only for specific events only.
View 1 Replies
View Related
Oct 1, 2004
I have a main form that calls several other forms for the user to input data. When the user closes one of the sub forms I would like to know what event is fired when the main form gets the focus back. I have tried several different events and can not figure out which one will work. Hopefully someone knows the answer I'm going crazy tring to figure it out, oh wait I'm already there.
Thank you
View 3 Replies
View Related
Mar 16, 2007
I have a database in which people add little bits to different fields as they go. For instance, person 1 puts in appointment, person 2 verifies info for the customer, person 3 checks the customer in, person 4 takes their money. What I am trying to do in a form is track the time when each department accessed it, and which user. I can do this on a new record, but for some reason, I can't get the event properties to work correctly on my form. I have a field for each department set aside for when they update their part of the record. What I am trying to do is, when the record is updated, having the time autopopulate the field.
Example:
Appointments enters |DATE OF APPT| |TIME OF APPT| Appointment timestamp should = time()
Verification enters |PATIENT INFO| |VERIFIED y/n| Verification timestamp should = time()
Reception enters |PULL TAB#| |CHECKED IN y/n| Reception timestamp should = time()
Cashier enters |AMOUNT COLLECTED| Cashier timestamp should = time()
All of these fields are on the same database (I have 2 linked tables: Customer demographics and appointments linked one to many by account # for the customer), and obviously, there's a lot more to it, but this is just a short example of what each department will enter. Appointments starts the appointment, so their timestamp will work, as they are starting new record. However, all of the following departments will be adding to this appointment record. When the other departments open their form with the fields in which they will be filling out, I want it to timestamp when they update the record as well as inserting their login "currentuser()" into the "updated by?" field for each department. For some reason, when I put time() into the event portion the field, it doesn't work. I tried it on dirty, on exit, after update, and it just doesn't update. Am I missing something?
View 5 Replies
View Related
Oct 26, 2004
I'm trying to get one combo box control what tables are available from another combo box. Example, combo box (a) includes numbers 1-5. Selecting (1) makes the data in combo box (b) specific to that selection. Selecting (2) makes the data in combo box (b) something different (pulls data from a different table).
Can anyone help me with this? Thanks!
View 1 Replies
View Related
Jun 19, 2005
Hi guys, ..and girls ;)
i have a calendar that works like a charm, but i would like to add the possibility to add recurrent events in it.
for instance if a user has to perform a task at a choosen time schedule, it is shown in the agenda, like each week or each two weeks or each month.
Anybody any idea how i would aproach this problem or has a sollution?
Thanks
View 1 Replies
View Related
Aug 19, 2005
Hi everyone,
I try to implement a function that looks for broken references in my Access project, so that I won't need to modify the needed references for every workstation. Here's my problem: Where could I put the call of this function so that this code will run before trying to compile the forms and, as a result, avoiding the compile error that access pops-up when a reference is broken or missing.
Thanks in advance! :D
View 1 Replies
View Related
Jun 23, 2007
I have a series of events that have a start date and an end date. How do I write an append query to append an event to a table as an individual event for every day in the given range?
View 2 Replies
View Related
May 13, 2005
I have a start and end date fields plus a txt box called wDays.
I'm trying to make sure the user puts in both dates but end cant be earlier than start and vs versa....
If not provide a message as to which is missing....
If alls well do the calulation with the module "GetWorkDays"
I f everything goes bad, dont save the record at all!
I have this behind a cmdButton. Used to unhide the wDays field because it displays #error otherwise...and to do the calculation... with the BeforeUpdate
Private Sub Command8_Click()
If IsNull(Me.sDate) Then
MsgBox "Please enter a Start Date"
ElseIf IsNull(Me.eDate) Then
MsgBox "Please enter a End Date"
Else
If Me.eDate < Me.sDate Then
MsgBox "End Date cannot be earlier than the Start Date"
Exit Sub
End If
End If
Me.Requery
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim myDays As Integer
If IsNull(Me.eDate) Or IsNull(Me.sDate) Then
Me.wDays.Visible = False
Else
Me.wDays.Visible = True
myDays = GetWorkDays([sDate], [eDate])
Me.wDays.Value = myDays
End If
End Sub
Any help would be really appreaciated because I have tried many combonations of code placement to get it working correctly....
View 1 Replies
View Related
May 26, 2005
Hello all:
I have a split, shared database in which the Before and AfterUpdate events on my forms are not working at all. I tried setting a breakpoint to verify this and, sure enough, they are not firing.
Does anyone have any clue as to why this may be occurring?
Thanks so much for the help. I have tried searching the forum with no luck.
View 2 Replies
View Related
Aug 15, 2005
I have a form with a number of controls with code behind - this works as required.
However, recently I decided to use a tabbed control to hold the controls and simply cut/pasted these control onto one of the pages of the tab control. The events now no longer fire as they did and I have no functionality on the form - the code still exists in the design of the form though..... any ideas?
View 1 Replies
View Related
Aug 15, 2005
Hello all,
I have a form where I want to validate enties before moving off the record.
I put my validation in the BeforeUpdate event of the form. If validation fails, then I set Cancel=True. So far, so good.
But if the user closes the form (either with my close button, or the standard close button), or presses 'Page down' to move to the next record, then even if validation fails, the form will close (or move record). What I want is for the user to be left with the form open, on the current record.
Can someoneon point me in the right direction ?
Thanks,
StepOne
View 1 Replies
View Related