Hi, all! After receiving a lot of help from ADezzi, Msquared, and NeoPa getting my ms access 2007 db functioning, I've run into another hitch that I haven't been able to solve. The database itself is saved on a MS Sharepoint server, and I would like users to be able to access it and execute the search query in read-only mode. In its current configuration, the query only "works" when the file is opened in "Edit" mode, and I've already had some problems with users inadvertently changing records returned by the user-defined query, which then changes the associated records in the source table.
The problem is, when a search is executed with the file opened in "read-only" mode, the following error message appears:
Error in SearchDB_Click( )
Cannot update. Database or object is read-only.
A simplified version of the VBA code linked to the "SearchDB" command button that builds the search query appears below:
This code does not include any of the criteria I've built in the "WHERE" statement, but I don't think the problem is here because all of the controls referenced are unbound (Control Source is blank), and I get the same error message whether I run the query with or without the criteria lines.
I don't want this query to update the database, just display selected records. The one thing it does do is allow the user to select which columns to display in the output table--could this be why the program "thinks" that the query is trying to update the database? Any help would be appreciated!
The problem is, when a search is executed with the file opened in "read-only" mode, the following error message appears:
Error in SearchDB_Click( )
Cannot update. Database or object is read-only.
A simplified version of the VBA code linked to the "SearchDB" command button that builds the search query appears below:
Code:
Private Sub SearchDB_Click() On Error Resume Next Dim ctl As Control Dim strSQL As String Dim strSQL_2 As String Dim qdf As DAO.QueryDef Dim qdfDemo As DAO.QueryDef Const conQUERY_NAME As String = "Search Results" For Each ctl In Me.Controls If ctl.ControlType = acCheckBox And ctl.Tag <> "" Then If ctl.Value Then strSQL = strSQL & ctl.Tag & ", " End If End If Next If strSQL = "" Then Exit Sub CurrentDb.QueryDefs.Delete conQUERY_NAME On Error GoTo Err_SearchDB_Click strSQL_2 = "SELECT " & Left$(strSQL, Len(strSQL) - 2) & " FROM [Table1];" Set qdfDemo = CurrentDb.CreateQueryDef(conQUERY_NAME, strSQL_2) DoCmd.OpenQuery conQUERY_NAME Exit_SearchDB_Click: Exit Sub Err_SearchDB_Click: MsgBox Err.Description, vbExclamation, "Error in SearchDB_Click()" Resume Exit_SearchDB_Click End Sub
I don't want this query to update the database, just display selected records. The one thing it does do is allow the user to select which columns to display in the output table--could this be why the program "thinks" that the query is trying to update the database? Any help would be appreciated!
Comment