smartpat19
Board Regular
- Joined
- Sep 3, 2014
- Messages
- 114
HI everyone,
My code is below. I want to have a button that will allow someone to add a record to access without having to open up the VBA editor to select the reference library.
Also if you know an easy way to create my own error message instead of the scary debug one (just incase someone freaks out in the office), that would be helpful as well.
ThanKS! Excel and access 2013
Pat
My code is below. I want to have a button that will allow someone to add a record to access without having to open up the VBA editor to select the reference library.
Code:
[COLOR=#333333]Private Sub CommandButton2_Click()MsgBox ("MAKE SURE THE ENTIRE INPUT TAB IS CORRECT")[/COLOR]
Application.ScreenUpdating = False
Dim db As database
Dim rs As DAO.Recordset
Set db = OpenDatabase("J:\samart\Projects\model output 2.0\discussion doc\Prelim data tape.accdb")
Set rs = db.OpenRecordset("Prelim List", dbOpenTable)
rs.AddNew
rs.Fields("Deal Name") = Sheets("import").Range("A2").Value
rs.Fields("Scenario") = Sheets("import").Range("B2").Value
rs.Fields("Deal Type") = Sheets("import").Range("C2").Value
rs.Fields("Shelf") = Sheets("import").Range("D2").Value
rs.Update
rs.Close
db.Close
Also if you know an easy way to create my own error message instead of the scary debug one (just incase someone freaks out in the office), that would be helpful as well.
ThanKS! Excel and access 2013
Pat