Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

{

"data": [

"Open a Form",

"DoCmd.OpenForm \"FormName\""

],

"Close a Form",

"DoCmd.Close acForm, \"FormName\""

],

"Navigate to a Specific Record on a Form",

"DoCmd.GoToRecord acDataForm, \"FormName\", acGoTo, RecordNumber"

],

"Run a Query (Create)",

"DoCmd.RunSQL \"INSERT INTO TableName (Field1, Field2) VALUES ('Value1', 'Value2')\""

],

"Run a Query (Read)",

"Dim rs As Recordset\nSet rs = CurrentDb().OpenRecordset(\"SELECT * FROM TableName WHERE


FieldName = 'Value'\")\nMsgBox rs!FieldName"

],

"Run a Query (Update)",

"DoCmd.RunSQL \"UPDATE TableName SET FieldName = 'NewValue' WHERE Condi�onField =


'Value'\""

],

"Run a Query (Delete)",

"DoCmd.RunSQL \"DELETE FROM TableName WHERE FieldName = 'Value'\""

],
[

"Open a Report",

"DoCmd.OpenReport \"ReportName\", acViewPreview"

],

"Filter Records on a Form",

"Me.Filter = \"[FieldName] = 'Value'\"\nMe.FilterOn = True"

],

"Message Box",

"MsgBox \"Your message here.\", vbInforma�on, \"Title\""

],

"Confirm Ac�on with a Message Box",

"Dim response As Integer\nresponse = MsgBox(\"Are you sure?\", vbYesNo, \"Confirm\")\nIf


response = vbYes Then\n ' Code to execute if Yes is clicked\nEnd If"

],

"Open an External Database",

"Dim db As Database\nSet db = OpenDatabase(\"C:\\Path\\To\\Database.accdb\")"

],

"Loop Through Records in a Recordset",

"Dim db As Database\nDim rs As Recordset\nSet db = CurrentDb()\nSet rs =


db.OpenRecordset(\"SELECT * FROM TableName\")\n\nDo While Not rs.EOF\n ' Your code here. For
example:\n MsgBox rs!FieldName\n rs.MoveNext\nLoop"

],

"Error Handling",

"On Error GoTo ErrorHandler\n' Your code here\n\nExit Sub\n\nErrorHandler:\nMsgBox \"An


error occurred: \" & Err.Descrip�on"

]
]

You might also like