automation through VBA code

hilbertm

Registered User.
Local time
Today, 00:32
Joined
Sep 7, 2001
Messages
46
I am new to VBA and trying to learn some code. I have developed a database with Access 97 and I am now just realizing the capibilities of access and VBA. I have many questions but right now I would like to know if code can be written for the following:

I would like to see a Dialog box with the message “enter order number to be removed”

When the number is entered, and a command button is pressed I need to check if the number entered is in one of 3 fields. Lets say order1 order2 or order3.

If number entered is not in these three fields, then an error message “no matches found, make sure the number is correct” should be displayed

If one of the order fields contains the number entered, I need the following to happen:
open a form (FORM1)
Make the following changes to the following fields
- delete the number in the matching order1, order2 or order3 fields
- delete a date in a date textbox1, date textbox2, or date textbox3
- delete a hyperlink in a hyperlink textbox1, hyperlink textbox2, hyperlink textbox3

If the record contains numbers in more than one order fields field, I need the data to be switched to the order1 field. So if there is data in FIELDS1 (order1, date textbox1, and hyperlink textbox1), and FIELDS2 (order2, date textbox2, and hyperlink textbox2), and the number in order1 is entered in the dialog box to delete it, I would like the data in FIELDS2 to switch to the FIELDS1 field.

I was also wondering if the deleted information can be moved to another access database or table for historical purposes.


I am also wondering if I can get an update message to pop up only if specific fields are updated. I am currently using the following code:
Private Sub Form_BeforeUpdate(Cancel As Integer)

On Error GoTo Form_BeforeUpdate_error
Dim intResponse As Integer
Dim strMSG As String
strMSG = "Data on the form has changed. Do you want to save changes?"
intResponse = MsgBox(strMSG, vbQuestion + vbYesNo, "Confirm Action")
Select Case intResponse
Case vbNo
Cancel = True
End Select
Form_BeforeUpdate_exit:
Exit Sub
Form_BeforeUpdate_error:
MsgBox Err & vbCr & Err.Description, vbExclamation, "Form_BeforeUpdate"
Resume Form_BeforeUpdate_exit

End Sub
but this gives the message for every field updated.

Thanks in advance for any help.

Mike
 

Users who are viewing this thread

Back
Top Bottom