Run-time error 3075

LuisV

New member
Local time
Today, 10:56
Joined
Oct 11, 2012
Messages
4
Good afternoon everyone. I am brand new to all of this -- I haven't even played with programming in more than 20 years. Anyhow, if y'all can help me out, I would appreciate it. I have created a form that upon opening asks the user to select a campus. They then need click the "OK" button. Upon doing so, a new form ("Campus_Select") should open up on the particular record selected. At this point, upon clicking on the "OK" button, the user gets the following message:

Run-time error '3075:'
Syntax error in string in query expression '[Name of School] = 'Adamson, W.H.'".

If I then select the "Debug" key on the pop-up window, I am taken to the VBA screen, where the following is highlighted:

DoCmd.OpenForm "Campus_Input", acNormal, , SelectedNameofSchool, acFormEdit, acWindowNormal

When the cursor is over "SelectedNameofSchool" I can see that the selected school is correct, so It seems that at least the school is being selected.

Here is my code:

Option Explicit
Private Sub Command1_Click()

Dim SelectedNameofSchool As String

SelectedNameofSchool = "[Name of School] = '" & Me![School_Choice] & "'"""

DoCmd.OpenForm "Campus_Input", acNormal, , SelectedNameofSchool, acFormEdit, acWindowNormal

End Sub

The code on my "Campus_Input" form is as follows:

Option Compare Database

Private Sub Form_Open(Cancel As String)
If Not IsNull(Me.OpenArgs) Then
Dim lngID As Long
Dim rs As Object

Set rs = Me.Recordset.Clone
lngID = Val(Me.OpenArgs)
rs.FindFirst "[Name of School] = '" & lngID
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End If


End Sub

Been trying to figure this out for a week. Your help is appreciated.

Aloha,

Luis
 
Not sure this will work, but you could try replacing:
SelectedNameofSchool = "[Name of School] = '" & Me![School_Choice] & "'"""
with:
SelectedNameofSchool = "[Name of School] = '" & Me![School_Choice] & "'"
 
Thanks, I made the change, then I got a new error:

Run-time error '2501:'
The Open-Form action was canceled.

Luis
 
Ok. Thanks for your help. I pieced a couple things together -- the problem was in the code for the 2nd window. I cleared all I had and just used a macro to close the 1st window.

Thanks. I used info from several threads.

Aloha!

Luis.
 

Users who are viewing this thread

Back
Top Bottom