Modules & VBA :: Event Information - Deleting Record Creates A Blank Record
Sep 8, 2013
I have a form set to the table Client Information with a subform set to the table Event Information. Client Information has a one to many relationship to Event Information.
There is a button that deletes the current record in Client Information--also deleting the related records in Event Information--then closes the form. The code works fine but a blank record in Event Information is apparently being created before the form closes.
Here's the VBA that I'm using:
Private Sub CmdDelReturn_Click()
Dim CmdDelReturnMsg As String
CmdDelReturnMsg = MsgBox("Delete event & client then return to front?", vbYesNo + vbDefaultButton1, "Delete and Return?")
[Code] ....
It's not a big deal because the button won't be used often and I can manually go into the table to delete the blank record. But if there's a simple solution to prevent this that would be nice.
How do I delete only one record in a table that has duplicate records using SQL?
Code: DELETE tblTemp.Fruit, tblTemp.[Country of Origin], tblTemp.Qty, tblTemp.Date, tblTemp.Currency FROM tblTemp WHERE (((tblTemp.Fruit)='Fruit') AND ((tblTemp.[Country of Origin])='Country of Origin') AND ((tblTemp.Qty)='Qty') AND ((tblTemp.Date)='Date') AND ((tblTemp.Currency)='Currency'));
I am trying to delete a record from a table and when I pass the variable as a text value it works but when I pass as a number I am getting a mismatch error.
I have to use it as a number as I am doing other update code in my database and it is a number.
Code: DoCmd.RunSQL "DELETE * FROM TblIssueData Where tblIssueData.SerNum = ' & Me.txtserNum & ';"
When I am using TblIssueData SerNum as a text variable in table it works but when I specify SerNum as a number in the table it gives me data mismatch error. I have to leave it as a number for other VBA code in my database. I believe it is just a syntax error but not sure where to go with it.
I have a Microsoft Access database with SQL Server backend with 10000 records in my table, I have a autonumber field and in my database the purpose of the autonumber field is just to keep the record sequence (not to treat as a unique identifier) and I don't want to use a number field to manually enter the sequence. Whenever the record is deleted or the user won't save the record, it put gaps in the record sequence, Is there any way to refresh the autonumbers automatically "After delete confirm" event or "After Insert/update" even.
What is the correct syntax that would delete a file when the record is deleted. The file's path is listed in a record field, MailLocation. Every time I try this code, I receive an error!
I've tried the below, and number of iterations, including calling the killfile differently (me![MailLocation], me.MailLocation).
Code: Private Sub Form_AfterDelConfirm(Status As Integer) Dim KillFile As String KillFile = me!MailLocation Kill KillFile End Sub
When I launch my modal, I want the user to be able to 'cancel' without creating a new record. It's not doing that and creating extra 'junk' in my table. How do I prevent that?
Here's my code: Private Sub Btn_Exception_SubModal_Click() DoCmd.OpenForm "Frm_Exception_UpdateModal", acNormal, , acFormAdd Forms! [Frm_Exception_UpdateModal]![clientnmbr].value = Me![clientnmbr].value End Sub
I have an ordering db that utilyzes the typical Form / Subform layout. I would like to be able to delete a record from the Main form and maintain the same postion relative to the other records. For example, if I am scrolling through the records and want to delete record #45, After I delete it I would like to be able to have record #44 visible to the user.
I am currently using (2) SQL statements to delete the records from the main Order table and the Order Details table which are linked without Cascade Delete Related Records being on.
I had set-up a recordset procedure to try and find the bookmark set before deletion but the only way I can get the sub-form to not show a blank form (no controls visible for the record just deleted and the #deleted in controls on the main form) is to requery after the delete, which loses the bookmark. If i place the ReQuery at the end it displays the records properly, (without the blank record) but returns the record to the first record. I have tried turning off any sorting references to OrderBy, etc. but it still returns to the first record.
I have also tried using "DoCmd.RunCommand acCmdDeleteRecord" but it doesn't delete the record from both tables.
I'm trying to add hidden information to a record and need to know the best way to do it.
I have a visible table that all users enter data into using a form.
I also have a hidden table that contains 2 fields "linked Table ID" and "notes"
I have a box at the top right of my form which is white (I also have a white background so it's impossible to see).
When you click the box it changes a textbox on my form visible property from false to true.
then I plan to use a separate button that the user currently uses to save a record to store ID number and hidden textbox information in the hidden table but I'm sure how to do this.
Finally I will use a hidden query which will display all the fields from both tables using the linked Table ID from the hidden table and ID field from the non hidden table.
So i have 2 questions:
1 how do I save information the user entered into a form created from one table into a different (hidden) table
I have a form with a number of fields and buttons on it. The form is opened in "add new record" mode. I have noticed that when I move from the last field in the tab order to the first field in the tab order it saves an entry in the database.
This is causing me problems because when users move from the last field in the tab order to the field in the tab order an entry is saved to the database but it by passes all the data checks ensuring that certain fields have been filled-in etc.
I don't know why the movement between these two fields is causing an entry to be saved. I don't have code associated with either of these objects. I aslo changed the last field in the tab order to a different field and it still happens.
Any ideas or suggestions would be greatly appreciated.
I have a form with a subform. In the form's On Current event I have the subform's visible property set to false. There is a button that when clicked sets the subform's visible property to true. I want the subform to go to the first control in a new record which is a combo box. the subform is a multiple items form. I have tried the GoToControl in the subforms OnCurrent event, but it is not working. I get an error saying the database cant find a third form.
I have a form that has a main for, a subform, and then another subform inside the 1st subform. The form works like this:
Conact info --->Call info and notes ---> Orders worked
Each of those being nested as they appear. The problem is, the user usually jumps strait to putting the order number in "Orders worked" before entering in any notes or info... So no record exists in it's parent form to tie to. How can I have the database create a new record in its parent form when the user types in the subform?
I have a form that uses a text box to search for a specific record in a table.(Cotton12) This works perfectly. What I would like to implement however is if the user so wishes he can edit the data he is shown, whithout editing the actual data in cotton12 and then with this new info create a new record in cotton13.
I have a form with a drop down that links to a table where a user can select or type a record, If they type a record that isn't in the table, the form goes completely blank.
Is there a afterupdate event I can do so that if the record doesn't exist, then a msg prompts and the form isn't completely blank?
I have a database which is slowly evolving. Users needed a feature to delete some records without a trail and some with a trail from the form. So I added an apply action field in the subform using which they can delete a record without a trail and if they wanted to keep a trail they could do that too. When user selects "Delete Violations as it was entered in error" the system deletes the record completely which is what everyone wanted.
After six months of use now I am asked to add an audit trail. I managed to do that also. I also looked at Browne's method but my data structure does not match the requirements for that method. I used an alternate method. It works as intended except when a record is completely deleted using the code I mentioned above. Then it goes in the infinite loop. I somehow need to bypass the before update event so that the function to write the audit trail is not called.
I've got a subform that im writing code for, once a user enters a value in one of the fields i want to make sure they cant change that field (and two other fields in that same record, though the rest of the fields are fine to edit at will)
I've got a function already written to validate the data in the record and decide whether or not the fields are enabled and disabled, however im having trouble finding an event in which to activate the function
Is there an event that triggers whenever a user selects a different record?
Any chart or list with all the handlers and how they trigger (in relation to each other) and when?
I have a list box that displays the contents of a back-end table that is has a new record added roughly 45 times per hour. I'd like the listbox to refresh automatically when a new record is added and, ultimately, notify the user that the new record is there. Are there any non-form events I can use to accomplish this? Right now, my workaround is to refresh the box once a minute using the form's timer. It works fine, but it's not pretty. Ideally, I could create some sort of event based on the new record being saved in the table.
Private Sub PrimaryDisability_Change() Select Case Me.PrimaryDisability Case "Other (Specify)" PrimaryOther.Visible = True Case Else
[Code] ....
My problem is that when I go to a new record, the fields that I want hidden in the new record unless they meet the criteria are still visible. I have looked all over online and in books to determine the code I use or whatever I need to do to make the field invisible in the new record and only to appear in each record if it meets the criteria.
I have several different sub-forms that have a button that opens a new form which creates a new record. Each of the different sub-forms have a field value that needs to be passed to the new record when the other form is opened. I've tried a few solutions, but to no avail. Right now I'm using the macro functionality as follows for one of the subforms:
The problem I think is that I'm creating a new record so the value doesn't get passed. The new record is only created after the user begins to enter data in the new form that was opened.
I created a basic database in Access 2013 to keep up with jobs, and each job has a job number assigned to make each job unique (Primary Key).
At first I had it where I had to enter the new job number manually for each job. I have updated it and now it takes the last job number and adds 1 to it and then fills in the Job Number field automatically.
The problem is when I clicked the Last Record button, it will go to the last existing record, but if I click the Next Record button while on the last record, it will create a new record. It creates a new job instead of stopping at the last record. I assume it has to do with the auto numbering I have setup for the job numbers, since it didn't do this before, but I am not sure why. I ONLY want to be able to click the New Record (Blank) button to create a new job, NOT by also clicking the Next Record button.
Is there a way to force only the New Record button to add a new record? I still need the Previous and Next Record buttons to maneuver through the existing records. I just don't want to create new jobs accidentally by clicking the Next Record button when I'm at the end of the existing records. It should just stop, or say last record or something similar.
I have a main form with several tabs. One of the tabs is a subform with just one number control, driven by a select query. The control shows a number, and you can type in a new number, which then updates the field in the table.
BUT, the control then shows a zero, it has moved to a blank record. If you enter a number again, it will attempt to write it to a new record.
So how do I display the number, and allow a new number to be entered that will update the SAME record, and not moved to a new record?
I need to write a query which populates an empty field in the current record with information from a specific field in the next sequential record. Any ideas?:confused:
I am new to access and I recently encountered a double click issue
My form loads perfectly on double click event but it shows the first record instead of selected record.
My search is based on a PersonID but each PersonID has different WorkID that I wish to display on double click but it always shows the first WorkID instead of my selected record
I have tried changing the filters in the form properties but it still doesn't work for me.
Here's my code:
Private Sub SearchResults_DblClick(Cancel As Integer) DoCmd.OpenForm "WorkForm", , , "[PersonID]=" & Me.[Searchresults], , acNormal End Sub
[Searchresults] draws information from my Query
Query information:
PersonID... WorkID... Type......Location 1234..........1............Paint .....Address A 1234..........2............Electric...Address B 1234..........3............Floor..... Address C
I am trying to achieve the following - I want to query a table to see if a record exists with a particular field blank. If so, I would like to prompt the user for data.
In real world terms, when assigning an item to a user I would like to first make sure that the item is not already assigned to somebody else. I have 4 fields, UserName, Item, IssueFrom, IssueTo. So when an item is assigned to a user, the first 3 fields are populated and the IssueTo remains blank, until that item is assigned to somebody else.
At the minute I have nothing in place to prevent a user from assigning the same item to multiple users and having multiple records for the same item in the table.
Hi All, I am looking for some help with a project I am working on where I need to automatically print a report from my database every time a new record is added to the table. The table contains 13 fields and the report needs to display 12 of them, the other being the index which is set to Autonumber.
The table is being updated solely by ODBC, this is working OK.
There is the potential for records to be added to the table very quickly via the ODBC link, so I need to safeguard that the report is being populated with correct information from the record that triggered the print event. Also, should multiple records be added in close succession, a report needs to be correctly generated/printed for each of one. The DB is to have no user intervention, and will just run on the PC at startup with all access menus/controls locked out.
Any information on how you think I should structure this, or any examples of helpful code that you might have would be very much appreciated.
I have some code for a button on click event to open a form and select the record which corresponds to a value in an unbound text box. The code is:
Private Sub Command25_Click() On Error GoTo Err_Command25_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "frmOpenPatientRecord"
[Code] ....
This works fine when I put in a 10 digit NHS number but opens a blank record when I enter a four digit or six character/digit PatientNumber. Both patient number and NHS number are text fields in the underlying table.