Access key combination allows users to press ALT key plus another key to focus or jump to a specific control.
Some controls have Access property where you can set this like TextBox or ListBox. As an alternative, you can set an Access key for a Label control and then tell the browser to associate it with another control. With this approach, you can use the Label control as caption to indicate the access key with an underlined letter.
To set the access key using label control you must:
1. Add the control to be associated
2. Add a Label control
3. Set the access key
4. Associate the control to receive focus
Here's an example:
<asp:Label ID="lblLastName" runat="server"
AccessKey="L"
AssociatedControlID="txtLastName"
Text="<u>L</u>ast name: ">
</asp:Label>
<asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
Note that setting focus by using access key from a Label control requires that client scripting is enabled in the browser.
Showing posts with label Access. Show all posts
Showing posts with label Access. Show all posts
Monday, August 13, 2007
Friday, June 8, 2007
Date Delimiter for Access and SQL Server
Microsoft's two most popular databases (MS Access & MS SQL Server) implement date delimiter differntly. This makes it hard to write queries that are compatible with both.
What I normally do this in situation would be creating a flag to indicate which database is being used and use the appropriate delimiter as follow:
Dim bAccessInUse As Boolean
Dim sSql As String
Function DateOut(byVal TheDate as String) as String
If bAccessInUse Then
Return "#" & TheDate & "#"
Else Return "'" & TheDate & "'"
End If
End Function
sSQL = "Select * From tablename Where date_col=" & DateOut(the_date)
If you use this function throughout your code and set and the flag by checking the connection string, you should have no problem making it run against either database without any modification.
What I normally do this in situation would be creating a flag to indicate which database is being used and use the appropriate delimiter as follow:
Dim bAccessInUse As Boolean
Dim sSql As String
Function DateOut(byVal TheDate as String) as String
If bAccessInUse Then
Return "#" & TheDate & "#"
Else Return "'" & TheDate & "'"
End If
End Function
sSQL = "Select * From tablename Where date_col=" & DateOut(the_date)
If you use this function throughout your code and set and the flag by checking the connection string, you should have no problem making it run against either database without any modification.
Labels:
Access,
ASP,
SQL,
VB,
VB.net,
Visual Basic,
Visual Basic.net
Wednesday, May 30, 2007
Basic SQL Syntax Troubleshooting
Developing dynamic web and/or desktop applications often involve querying the database for the desired data. One of the problems new programmers often run into is troubleshooting SQL syntax.
Here's a simple tip to help you troubleshoot your SQL syntax:
1. Write the SQL statement out to screen
2. Copy the SQL statement
3. Open the Access database
4. Create a new query
5. View the query text
6. Paste the SQL statement in the query window
7. Try to run the SQL statement
This should give you more info about the error you are running into.
But I am using SQL Server instead of Access database...
Don't worry, if you are running SQL Server or other databases, you can use Access and created linked tables to your database and take it from there.
Here's a simple tip to help you troubleshoot your SQL syntax:
1. Write the SQL statement out to screen
2. Copy the SQL statement
3. Open the Access database
4. Create a new query
5. View the query text
6. Paste the SQL statement in the query window
7. Try to run the SQL statement
This should give you more info about the error you are running into.
But I am using SQL Server instead of Access database...
Don't worry, if you are running SQL Server or other databases, you can use Access and created linked tables to your database and take it from there.
Subscribe to:
Posts (Atom)