Microsoft Access 2013 GUI App Created 2014 published 190526

In Microsoft Access 2013 it is very easy to create a sGUI to work with a database with help of Visual Basic.

I created an example that can be shown in figure 1:

Figure 1: Access 2013 database GUI in Visual Basic

First create a database, then choose "Create" -> "Form Design"

Design your GUI with Buttons and  textboxes.

The current primary key is selected in the form property "Data"->"Record source" and can be a SQL statement like:

SELECT Tabell1.ID, Tabell1.namn, Tabell1.lname FROM Tabell1 WHERE (((Tabell1.ID)=2)); 

This is also the property that the buttons will change.

To create a full screen GUI you nedd to the this (also shown in figure 2)

first make sure to create a subrutine:

    DoCmd.Maximize
End Sub


then in the forms property set:
form tab:
Border Style to ‘dialog’
Set Auto Resize to ‘Yes’
set Auto Center to ‘Yes’

Turn off:
Control Box
Dividing Line
Min Max Buttons

Decide what to do with:
Record selections
Scroll bar

If you turn off "Close Button" you can not close the
app unless you use task manager and kill the process.


Figure 2: Forms property to be change to be able to create a full screen GUI.

Here  is the visual basic code for the buttons:



Private Sub Form_Close()
    On Error GoTo Err_cmdCloseForm_Click
 
    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.Close
 
Exit_cmdCloseForm_Click:
    Exit Sub
 
Err_cmdCloseForm_Click:
 MsgBox Err.Description
 Resume Exit_cmdCloseForm_Click
End Sub

Private Sub Form_Load()
    DoCmd.Maximize
End Sub

Private Sub Kommandoknapp6_Click()
    Dim cmdstr As String
    cmdstr = "SELECT Tabell1.[ID], Tabell1.[namn], Tabell1.[lname] FROM Tabell1 WHERE (((Tabell1.[ID])=3))"
    RecordSource = cmdstr
End Sub

Private Sub Kommandoknapp7_Click()
    Dim cmdstr As String
    cmdstr = "SELECT Tabell1.[ID], Tabell1.[namn], Tabell1.[lname] FROM Tabell1 WHERE (((Tabell1.[ID])=2))"
   RecordSource = cmdstr
End Sub

Private Sub Kommandoknapp8_Click()
    Dim cmdstr As String
    cmdstr = "SELECT Tabell1.[ID], Tabell1.[namn], Tabell1.[lname] FROM Tabell1 WHERE (((Tabell1.[ID])=1))"
    RecordSource = cmdstr
End Sub

Finally here are the source files:
Database3.accdb
VisualBasicCode.txt