In Access, the CurrentUser function returns the name of the current Access user. In a secured database, this would be the name of the user who has logged in. If the database is unsecured, this function would return Admin (the default account) as the name of the user.
The syntax for the CurrentUser function is:
CurrentUser()
VBA Code
The CurrentUser function can be used in VBA code. For example:
Dim LUser As String
LUser = CurrentUser()
In this example, the variable called LUser would now contain the name of the user currently logged into the Access database.
SQL/Queries
You can also use the CurrentUser function in a query.
torstai 30. elokuuta 2007
keskiviikko 29. elokuuta 2007
Howto INSERT from MS Access forms
' AutoNumber field is updated automatically if one exists
Private Sub Command1_Click()
Dim SQLI As String
SQLI = "INSERT INTO MYMOVIES ([GENRE],[NAME],[PRODUCTIONYEAR]) " & _
"values ('" & Forms!AddMovie!Genre & "'," & Forms!AddMovie!Name & _
Private Sub Command1_Click()
Dim SQLI As String
SQLI = "INSERT INTO MYMOVIES ([GENRE],[NAME],[PRODUCTIONYEAR]) " & _
"values ('" & Forms!AddMovie!Genre & "'," & Forms!AddMovie!Name & _
"," & Forms!AddMovie!ProductionYear & "');"
DoCmd.RunSQL SQL_InsertFilm
Response = MsgBox("You added ' " & Forms!AddMovie!FilmName & " '.")
End Sub
DoCmd.RunSQL SQL_InsertFilm
Response = MsgBox("You added ' " & Forms!AddMovie!FilmName & " '.")
End Sub
tiistai 28. elokuuta 2007
DoCmd.RunSQL
Dim SQL_UpdateCategory2 As String
SQL_UpdateCategory2 = "UPDATE tCateg2 SET lastdrwno =" & Me.drwno & " WHERE Cat2 = '" & Me.cat2 & "'"
DoCmd.RunSQL SQL_UpdateCategory2
SQL_UpdateCategory2 = "UPDATE tCateg2 SET lastdrwno =" & Me.drwno & " WHERE Cat2 = '" & Me.cat2 & "'"
DoCmd.RunSQL SQL_UpdateCategory2
Visual Basic String constants
Constant Definition
-------------------------------------------------------------------
vbBack A backspace character [Chr(8)]
vbCr A carriage return [Chr(13)]
vbCrLf A carriage return and line feed [Chr(13) + Chr(10)]
vbLf A linefeed [Chr(10)]
vbNewLine A platform-specific new line character, either
[Chr(13) + Chr(10)] or [Chr(13)]
vbNullChar A null character of value 0 [Chr(0)]
vbNullString A string of value 0 [no Chr code]; note that this is
not the same as ""
vbTab A tab character [Chr(9)]
-------------------------------------------------------------------
vbBack A backspace character [Chr(8)]
vbCr A carriage return [Chr(13)]
vbCrLf A carriage return and line feed [Chr(13) + Chr(10)]
vbLf A linefeed [Chr(10)]
vbNewLine A platform-specific new line character, either
[Chr(13) + Chr(10)] or [Chr(13)]
vbNullChar A null character of value 0 [Chr(0)]
vbNullString A string of value 0 [no Chr code]; note that this is
not the same as ""
vbTab A tab character [Chr(9)]
maanantai 27. elokuuta 2007
DLookUp
Me.drwno = DLookup("lastdrwno", "tCateg2", "cat2='" & Forms!AddDrawing!ComboCat2 & "'") + 1
is same as :
SELECT
lastdrwno
FROM
tCateg2
WHERE
cat2 = Forms!AddDrawing!ComboCat2 + 1
http://msdn2.microsoft.com/en-us/library/aa172176(office.11).aspx
is same as :
SELECT
lastdrwno
FROM
tCateg2
WHERE
cat2 = Forms!AddDrawing!ComboCat2 + 1
http://msdn2.microsoft.com/en-us/library/aa172176(office.11).aspx
keskiviikko 22. elokuuta 2007
Dateformats in MS ACCESS Forms
Between DateValue([Forms]![SearchForm]![txtDueDateA]) And DateValue([Forms]![SearchForm]![txtDueDateB])
is usable for coverting strings to date for SQL.
is usable for coverting strings to date for SQL.
Tilaa:
Kommentit (Atom)