Modules & VBA :: Add Record Name To Deletion MsgBox

Aug 19, 2013

I'm using this stardard piece of code on a button that deletes a record from a simple continuous contact form.

Code:
If MsgBox("Do You Want To Delete This Record?", vbQuestion + vbYesNo + vbDefaultButton2, "Delete?") = vbYes Then
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
End If

If the form is called "CONTACTS" with a field called "Contact_Name", what code do I use to have the relevant Contact_Name appear in the MsgBox to be sure that I'm deleting the correct record ...... something like this .....

Do You Want To Delete The Record Called Paul Quinn ?

View Replies


ADVERTISEMENT

Modules & VBA :: Reset Autonumber After Record Deletion

Jul 16, 2015

We need to reset the autonumber after the last record is deleted.

For example:
2006
2007
2008

if 2008 gets deleted, we want the autonumber to reset back to 2008 rather than move to 2009.

Is this possible? This is the code we are using but cannot get the string to recognize the variable. If the variable is replaced with a number, it works, but it defeats the purpose of adding the plus 1 to the last autonumber.

Code:
Private Sub Command0_Click()
Dim RLMax As Integer
Dim Statement As String
RLMax = DMax("[id]", "Table1")
RLMax = RLMax + 1

strSQL = "Alter table table1 Alter Column Id Autoincrement(RLMax,1)"
DoCmd.RunSQL strSQL
End Sub

I realize we don't want to depend on the autonumber for anything other than a row identifier, but the table is setup that it is important for the rows to be sequential if the last record is deleted. Only if the last record is deleted.

View 12 Replies View Related

Record Deletion In My Forms

Apr 14, 2006

I have a form with a sub-form and a sub-sub-form :p
If I try to delete the record being viewed in the sub-form using
With DoCmd
.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End With

Then I here a ding (like you do when you try to delete a record) but I see no record delete confirmation box come up, if I hit enter, it deletes. So its there, but I can't see it, it's not behind the form either.
Any ideas?
Cheers

View 2 Replies View Related

Record In Subform Won't Allow Deletion

Jul 20, 2005

hiya

i have a subform which won't allow me to delete a record unless i'm in the datasheet view. is there anyway to change this. the properties have been set to allow deletions.

thanks
trish

View 7 Replies View Related

Incrementing Counter And Record Deletion

Apr 1, 2007

Hi,

The user wants all of the records in the database to have continuous numbering. I have used AutoNumber in the past but if you delete a record, it produces gaps in the numbering.

I was wondering if there is a way to number the records so they are always numbered continuously (1,2,3,etc.) even if some record is deleted.

I have tried using the following:


Set db = CurrentDb()
Set recordlist = db.Openrecordset("SELECT Max(tblContactHistory.ItemID) AS MaxID FROM tblContactHistory")

ItemID = (recordlist!MaxID + 1)

recordlist.Close
Set recordlist = Nothing


but I still cannot get the records to have continuous numbering after a record is deleted.


Any helped would be appreciated.

Thanks!

View 1 Replies View Related

Custom Record Deletion Sequence

Aug 7, 2007

I want to create a custom sequence when deleting a record but I'm having a problem.

What I want to do is prompt the user for the reason he/she is deleting the record and then archive this so it can be viewed in a log at a later time. This extra step is not as easy as I thought it would be.

What I did was put some coding into the On Delete event of the form. The code opens a form with a text box. The user can enter the reason for the delete in the text box and click OK or click cancel to abort the deletion.

My problem here is opening another form from the On Delete event. As soon as the form is open, the code just passes to the next step of the sequence and deletes the record.

There are 2 approaches that I've thought of but I'm not happy with either.

Approach 1:
In the On Delete event, set Cancel to True. That way the deletion is not handled by the delete sequence but rather by the new form that opens. The problem is that deleting a record from another form is not that simple. What I've tried is to execute a SQL statement that grabs the ID of the record from the open form and delete it. The problem is that although the record is deleted, all the fields on the form say #Deleted in them which is not that pretty. (Maybe there's some other way to do the deletion without this problem that I'm not aware of...?)

Approach 2:
Use an Inputbox. Unlike a custom form, the Inputbox delays execution of the code so the code can determine from the results (i.e. should it cancel the delete if the user clicked Cancel). The problem with Inputboxes is that they are not very flexible in the layout, they look pretty "packaged" (i.e. they look to me like the programmer didn't bother creating a means to enter a value). There's no way to place the buttons where you want or have it do better validation (e.g. I want the FORM to check that there's at least a few words describing why the user is deleting the invoice rather than have the form with the record get the input message passed back and then give an error and then pop open the Inputbox again)

I think that especially when you're creating an application with anything financial, you'll want to log a deleted invoice including the date, amount, possibly the client's name, invoice number, reason for deletion and the login name of the person doing the deletion. All of these are easy to record other than the reason.

Help would be much appreciated.

SHADOW

View 5 Replies View Related

Problem Inserting A Record After A Deletion

Apr 25, 2006

I have a form and a subform. There are a number of buttons on the form, allowing me to add, update, delete, etc. records from the subform. The process is that I select a record on the subform, its details are displayed on the form, then clicking on <Delete>, for example, removes it.

Each of these processes work fine on their own and also if carried out one after the other, for the most part. The one problem I'm finding is when I delete a record.

Firstly, the subform appears to refresh and the record is no longer shown. However, if I then try to select another row from the subform, I get a message saying 'record is deleted'. I click on <OK> to remove this message and I can then select the same row or another row without any problems.

Secondly, if I now try to add a new record (the code behind the button is just 'DoCmd.GoToRecord , , acNewRec'), I get a message saying that I can't go to the selected record.

If I close and reopen the form between each activity, all works fine, suggesting that something isn't refreshing properly. I've tried putting 'Me.refresh' and 'Me.requery' immediately after running the deletion, but to no effect.

Any suggestions?

View 5 Replies View Related

Table With Key In Two Fields - Record Deletion

Oct 21, 2015

I have a table whose key is two fields. I am having no luck in selecting a given record from a form and deleting it. No problem in a table with a single field key.

View 14 Replies View Related

Modules & VBA :: Deletion In Table From Input Box

Mar 1, 2015

I'm having trouble executing a SQL command in VB... I want it to find the the value of the input box in TBL-Purchases and Delete all related values. Here's my code.... I get an error on the line I've highlighted in green...

Private Sub Command31_Click()
Dim Message, Title, Default, MyValue1, MyValue2
Title = "Sell Stocks"
Default = ""
MyValue1 = InputBox("Which stock ticker name would you like to sell?")
MyValue1 = UCase(MyValue1)

[Code] .....

View 9 Replies View Related

General :: Unwanted Deletion Related To Particular Record In Conversation Table

Mar 6, 2013

I have 2 tables.
1- customers table with 2 fields : customername,customerno
2-conversationstable with 4 fields: date,customername,customerno,details

The conversations table is for keeping memo of telephone conversations with the customers.

I built a simple form deriving from the conversations table. And added to it a combobox with 2 columns from customers table to select the customername an customerno for the form.

While deleting the record in the conversations table,through the form, I saw that the customername and customerno in the customers table of that particular customer record are deleted also. I made no links between both tables.

I wonder why that happened.

View 1 Replies View Related

Matrix View Allowing Checkbox For New Record Creation / Deletion?

May 29, 2013

What I would like to do it take all 'RoleTitle' from RolesList, all 'CourseID' from courselist and show them as a pivot table/matrix with a checkbox that creates or deletes entries from the RoleRequirements table. So, if it exists in the RoleRequirements table then it should appear a checked, unchecking it would delete it from the table.

I am using access 2010 with a SQL server 2005 backend.

View 3 Replies View Related

Modules & VBA :: Prevent Deletion Or Changes To Records That Meet Certain Conditions

Jun 14, 2013

Been experimenting on some code to prevent deletion or changes to records that meet certain conditions.

The problem I am having is the code is contradicting each other preventing some of the records to be locked down.

Code:
Private Sub Form_Current()
'Code 1 - Prevent edits if 21 day period has lapsed
If TestDate2(Me.txtStartedHidden) > 0 Then
MsgBox "Editing NOT allowed - 21 day time period has been reached"
Me.txtBasic.Locked = True

[Code] ....

Rules are:

Edits allowed if invoice date not reached
Edits allowed if within 21 day but NOT if invoice date is reached

Edits prevented if invoiced date reached and if records still within 21 days
Edits prevented if invoiced date reached & records past 21 days

View 2 Replies View Related

Forms :: Combo Box Search - If Record Not Exist It Will Display Msgbox To No Record Found

Oct 28, 2014

I have a problem with my database I have a combo box that will search for my record. Actually its working I input the specific number it goes to the specific record. But I want, if there no existing record in my database it will display a Messagebox that "No record Found" I try to put a code in a macro builder in a after update property field but nothing happened.

Expression code that it will display the msgbox if there's no record found.

the given code from macro builder is attached. I try to have an if else statement but I dont know how to not equal that giver conditional expression.

View 10 Replies View Related

Making A MsgBox Appear After A Blank Record Is Shown?

Mar 10, 2005

hi,
i have a form, which when opened, gives me a blank record. which is what i asked it to do in the OnOpen property. however, i also need a msg box to popup - but after the form has been opened. i tried placing both pieces of 'code' into the OnOpen property, however, the popup displays first, then the form opens.

so currently i have:

Private Sub Form_Load()
Select Case MsgBox("Please select the Registration Number from the drop down menu or type it in", vbOKOnly, "Select Registration Number")

End Select
End Sub
--------------------------------------------------------------------------
Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec

End Sub
--------------------------------------------------------------------------

but it does the same thing. so, is there a way to make the msg box appear after the form opens with a blank record?
thank you in advance :D

View 3 Replies View Related

Forms :: DLookup And MSGBOX With Record Details

Jun 18, 2015

I've got a form which holds data for employees, fname, lname, ..... and an entered date which defaults to now().

On the before update event, i have the following.

Code:
If DCount("*", "trainingdata", "[Empid]=" & Me!EmpID & _
" And [subjectid]=" & Me!SubjectID & _
" And [trainingdate]=#" & Me!TrainingDate & "#") > 0 Then
MsgBox ("This record already exists")
Cancel = True
Me.Undo
Me.SubjectID.SetFocus
End If
End Sub

With the above vba code, a msgbox pops up if the record combination already exists. What I would like to do is in the same msgbox have the "entered" date display and make the msgbox say something like.

This record already exists and was entered on 6/18/2015, [entered]...

View 5 Replies View Related

Not Null, Msgbox, Ammend Record - Bringing It All Together For A Newbie

Mar 27, 2006

Hi all,

New to this, but found some helpful tips/code already that I've integrated into my project.

You may well be familar the issue tracker database available for download from Office Online, well I'm using this for a little project I'm running.

What I want to do is tie up a few snippets as follows:

1-On my form I have a button called "Close"
2-When I click the Close button I want to check two fields, "closure" and "fix" and ensure that they have content i.e. not null
3-If they have content then I want to alter the "Status" field of the displayed record from Open or Suspended to closed (these are the three options for this field)
4-If the "closure" and/or "fix" fields are empty then I want a msgbox to pop up promting the user to fill out the relevent field/s, otherwise mark the record as closed

So;

Click close button, check contents of two fields, pop up a message if either or both empty, enter details in empty field/s, click button again and as both fields are now complete,mark the records status field as closed.

I've got so far but can't quite tie it all together, is what I'm asking possible? What do you need from me to help answer the question?

Thanks very much for your help.

View 4 Replies View Related

Forms :: Combo Box With Msgbox If Selected Item Is Not In Record

Oct 30, 2014

I want a Messagebox to be appear if the selected item or if the input item in the combobox was not in the record.

I used this condition in combobox

="[asstnumbr] = " & "'" & [Screen].[ActiveControl] & "'"

but when I try this run code function in macro via IFF will become error

IIf([asstnumbr]<>"'" & [Screen].[ActiveControl] & "'",MsgBox("NO RECORD FOUND IN YOUR SEARCH"))

View 1 Replies View Related

Modules & VBA :: Yes / No Buttons Not Working On Msgbox

Oct 30, 2013

I have a form I use to search for clients when I hit a command button, using surname etc. I'd like a yes no button to pop up rather than the clunky ok button route I currently have. I'm a beginner with VBA and most this I've gleaned from internet.

If there are matching results, everything is fine. If there are no matching results, I've managed to get my desired messagebox come up by using the code below in the onload event of the resulting search results form, however the yes no buttons do nothing and the results form loads blank as though no records were found.

I'd like Yes to send users to the client input form, and No to return them to the search form.

Private Sub Form_Open(Cancel As Integer)
If Me.Recordset.RecordCount = 0 Then
MsgBox "Do you want to add a new Client?", vbQuestion + vbYesNo, "No clients found"
Select Case intanswer
Case vbYes

[Code] .....

View 9 Replies View Related

Modules & VBA :: Msgbox With Combobox Value Ii Not In List Event

Jan 23, 2015

I currently use this code to trigger a not in list event, ask the user if they want to add it to the respective table, and then add it.

I'd like to be able to add the text in the combo box that triggers the event to show up in the msgbox.

Private Sub cboCategory_NotInList(NewData As String, Response As Integer)
Const Message1 = "The data you have entered " & me.cbocategory.text &" is not in the current dataset."
Const Message2 = "Add now?"
Const Title = "Unknown entry in CATEGORY Field..."
Const NL = vbCrLf & vbCrLf

[Code] ....

View 2 Replies View Related

Modules & VBA :: Current Time And Date On Msgbox?

May 4, 2014

How can i display current time and date on msgbox. in ms access 2007.

View 2 Replies View Related

Modules & VBA :: Msgbox To Confirm Changes To Specific Control

Oct 3, 2013

I have a database in which users have the ability to search by last name...nothing fancy there. However, the users continue to forget to click the Find Client button and instead just type what name they are looking for in the LASTNAME control thus changing the record that they are currently in!!!

I am looking for a way to have a msgbox pop up any time the LASTNAME control is changed. I found the code below but this works for the entire record and I don't want them to have to click Yes every time they make change.

Code:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If MsgBox("Changes have been made to this record." _
& vbCrLf & vbCrLf & "Do you want to save these changes?" _
, vbYesNo, "Changes Made...") = vbYes Then
DoCmd.Save
Else
DoCmd.RunCommand acCmdUndo
End If
End Sub

View 4 Replies View Related

Modules & VBA :: Msgbox Before Opening Excel Sheet

Sep 4, 2013

I have a query, which looks like that:

ID Year SAP Geris
1 2008 20,00 € 5,00 €
1 2009 40,00 € 4,00 €
1 2010 60,00 € 6,00 €
2 2007 80,00 € 4,00 €
2 2008 100,00 € 8,00 €
2 2009 100,00 € 4,00 €
3 2008 1.000,00 € 1,00 €
3 2009 100,00 € 8,00 €
3 2010 2,00 € 9,00 €
4 2008 9,00 € 10,00€

So each combination has an ID. It's called the SuWID. I want to Transfer the data to a fixed Excel sheet. I wrote the following code

Dim xlApp As Object ' Excel.Application
Dim xlBook As Object ' Excel.Workbook
Dim xlSheet As Object ' Excel.Worksheet
Dim rst As DAO.Recordset
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True

[Code] ....

The only Thing what i still want to have is that, before it opens the Excel form, which works already perfectly well, that a msgbox will Show up and ask me, which SuWID do you want to see in the Excel sheet.

View 14 Replies View Related

Modules & VBA :: How To Open Report From Msgbox With A Condition

Jan 13, 2014

i have a form to enter a new client if the client is existed then a message box appear and tell me that this client is existed and his number id is ## with two buttons yes and no.if i click yes i should go to a report that contains information about that user and this report take his data from a query

new client save code
---------------------
Dim MSG As Integer
Dim ExistentID As Long
ExistentID = Nz(DLookup("P_ID", "tbl_Personal_Information", "Full_Name = Forms!frm_New_Person!F_N"), 0)
If ExistentID > 0 Then

[code]....

when i click yes the report should open with the existent id but he open a input box to ente an id and his title is tbl_personal_information.PID it's the ID field that it's named P_ID in the query

View 4 Replies View Related

Modules & VBA :: Show Msgbox If Search Is Empty - Error 94

Sep 19, 2014

I have a button that opens a form which is based on a query.

The query has a prompt so when you click the button the prompt pops up.

However if nothing is entered you get a VB error 94 error.

How do i get it to show a msgbox if the search is empty?

View 4 Replies View Related

Modules & VBA :: Access 2013 - How To Write Two Line Msgbox

Jan 20, 2014

how to write a vba msgbox with two lines i access 2013

i try to put chr(13) and alse i used & vbCrLf& but nothing is worked

they seems to be for an earlier version ...

View 6 Replies View Related

Modules & VBA :: Possible For A Msgbox To List All Records Where A Field Equal To Value?

May 18, 2015

So I have a form for addresses that checks against a table of US zip codes, and throws up a warning if the City/State/Zip entered isn't found on the table. This works great. But I was wondering if there was a way to list the available combinations based on the zip code entered. I want the program to tell the user that the city is wrong, but here is a list of what it could be.Is it possible for a msgbox to list all records where a field = value?

View 11 Replies View Related







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