473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Error 3075, 2448: Cannot Assign Value - Access 2003

Dököll
2,364 Expert 2GB
Hey gang!

Below code allows me to search my database though all fields included on the form. Works great. Small issue, when I fetch partial phrases, if they contain an apostrophy, say, "Ferris Bueller's Day Off", Access does not understand it an gives me either ther 3075 error, or the other.

What are your thoughts on that?

Option Compare Database
Option Explicit

'Refresh form screen for new data entry
Private Sub ResetMeScreen_Click()
DoCmd.Close 'the form must close, then reopened
DoCmd.OpenForm "DataCentralReport"
End Sub
'Search button
Private Sub SearchMeData_Click()
Const cInvalidDateError As String = "Please enter date in proper format to continue..."

'Date format catcher. This keeps the data clean and standard
Dim strWhere As String 'Dimensioned to be called through command
Dim strError As String 'Dimensioned to be called below
strWhere = "1=1"
If Not IsNull(Me.AsTo) Then 'Loads data searched if available
strWhere = strWhere & " AND " & "DataCentral.[AsTo] = '" & Me.AssignedTo & "'"
End If
If Not IsNull(Me.OpToThen 'Loads data searched if available
strWhere = strWhere & " AND " & "DataCentral.[OpTo= '" & Me.OpenedBy & "'"
End If
If Nz(Me.Status) <> "" Then 'Loads data searched if available
strWhere = strWhere & " AND " & "DataCentral.[Status] = '" & Me.Status & "'"
End If
If Nz(Me.Category) <> "" Then 'Loads data searched if available
strWhere = strWhere & " AND " & "DataCentral.[Category] = '" & Me.Category & "'"
End If
If Nz(Me.CoName) <> "" Then 'Loads data searched if available
strWhere = strWhere & " AND " & "DataCentral.[CoName] = '" & Me.CoName & "'"
End If
If Nz(Me.Code) <> "" Then 'Loads data searched if available
strWhere = strWhere & " AND " & "DataCentral.[code] = '" & Me.Code & "'"
End If
If Nz(Me.Priority) <> "" Then 'Loads data searched if available
strWhere = strWhere & " AND " & "DataCentral.[Priority] = '" & Me.Priority & "'"
End If
If IsDate(Me.BeginningDate) Then 'Loads data searched if dates available
strWhere = strWhere & " AND " & "DataCentral.[TodayDate] >= " & GetDateFilter(Me.BeginningDate)
ElseIf Nz(Me.BeginningDate) <> "" Then
strError = cInvalidDateError
End If
If IsDate(Me.EndingDate) Then 'Loads data searched if dates available
strWhere = strWhere & " AND " & "DataCentral.[TodayDate] <= " & GetDateFilter(Me.EndingDate)
ElseIf Nz(Me.EndingDate) <> "" Then
strError = cInvalidDateError
End If
If Nz(Me.ContactPerson) <> "" Then 'Loads data searched if available
strWhere = strWhere & " AND " & "DataCentral.ContactPerson Like '*" & Me.ContactPerson & "*'"
End If
If Nz(Me.Items) <> "" Then 'Loads data searched if available
'Like helps get part of the text then searched
strWhere = strWhere & " AND " & "DataCentral.Items Like '*" & Me.IssuesItems & "*'"
End If
'If Nz(Me.LegacyDate) <> "" Then 'Loads data searched if dates available
'strWhere = strWhere & " AND " & "DataCentral.LegacyDate Like '*" & Me.LegacyDate & "*'"
'End If
If Nz(Me.ID) <> "" Then 'Loads data searched if dates available
strWhere = strWhere & " AND " & "DataCentral.ID Like '*" & Me.ID & "*'"
End If


If strError <> "" Then 'Pop up catch when search is cancelled
MsgBox "You decided to cancel your search..." 'strError
Else
If Not Me.FormFooter.Visible Then 'results loads in additional form in footer
Me.FormFooter.Visible = True
DoCmd.MoveSize Height:=Me.WindowHeight + Me.FormFooter.Height
End If
Me.DataCentralResultsForm.Form.Filter = strWhere
Me.DataCentralResultsForm.Form.FilterOn = True
End If
End Sub
Function GetDateFilter(dtDate As Date) As String
GetDateFilter = "#" & Format(dtDate, "MM/DD/YYYY") & "#"
End Function
Any information you have is appreciated.

My apologies re; Code tags, too long of a procedure, couldn't add CODE=VB.

Have a great week-end, thanks!

Dököll
Nov 30 '07 #1
8 2536
Rabbit
12,516 Expert Mod 8TB
Do a Replace on the string to change all single quotes to double single quotes.

'He's'
That confuses the SQL engine because it will see 'He' as a string but will not know what to do with s'. Double single quotes tell it to use the character and not to break the string and that the string continues on.
Nov 30 '07 #2
Dököll
2,364 Expert 2GB
Do a Replace on the string to change all single quotes to double single quotes.

'He's'
That confuses the SQL engine because it will see 'He' as a string but will not know what to do with s'. Double single quotes tell it to use the character and not to break the string and that the string continues on.
Pretty special, will give that a whirl!

Thanks:-)
Dec 1 '07 #3
Rabbit
12,516 Expert Mod 8TB
Good luck.
Dec 1 '07 #4
Single quotes can create headaches, but you can put this in a standard module & then use it any time you're searching for strings. It doubles-up any single quotes as Rabbit said. It accepts a Variant, so NULLs won't break it, it just returns a zero-length string.

Expand|Select|Wrap|Line Numbers
  1. Function FixQuotes(text) As String
  2.     If Len(Nz(text, "")) = 0 Then Exit Function
  3.     FixQuotes = Replace(text, "'", "''")
  4. End Function
  5.  
Dec 1 '07 #5
Dököll
2,364 Expert 2GB
Hey gang!

It looks like removing single quotes in this case redenred the search unusable. I am certain I am missing the big picture:

Expand|Select|Wrap|Line Numbers
  1.  
  2. If Nz(Me.ID) <> "" Then 'Loads data searched if dates available
  3. strWhere = strWhere & " AND " & "DataCentral.ID Like '*" & Me.ID & "*'"
  4. End If
  5.  
  6.  
  7.  
I really need to rid of the error for the above portion. I intend to remove the Like operator for the others.

So removing the single quotes in above give me error number: 3075, as in the previous.

It's probably pretty simple:-)

In a bit, and thanks!
Dec 7 '07 #6
Dököll
2,364 Expert 2GB
I wondered if something like this would work to catch the error popping up:

Expand|Select|Wrap|Line Numbers
  1.  
  2. If Err.Number = 3075 Then
  3.         .....
  4.      Else
  5.         .....
  6.      End If
  7.  
  8.  
Perhaps I can surpress the incoming error to tell VBA it's okay to process. Will let you know...
Dec 7 '07 #7
Rabbit
12,516 Expert Mod 8TB
Hey gang!

It looks like removing single quotes in this case redenred the search unusable. I am certain I am missing the big picture:

Expand|Select|Wrap|Line Numbers
  1.  
  2. If Nz(Me.ID) <> "" Then 'Loads data searched if dates available
  3. strWhere = strWhere & " AND " & "DataCentral.ID Like '*" & Me.ID & "*'"
  4. End If
  5.  
  6.  
  7.  
I really need to rid of the error for the above portion. I intend to remove the Like operator for the others.

So removing the single quotes in above give me error number: 3075, as in the previous.

It's probably pretty simple:-)

In a bit, and thanks!
Removing single quotes? We never said to remove single quotes. You have to do the opposite. In a string with single quotes, you have to double up on the single quotes.

Also, that snippet of code shouldn't throw an error in of itself.
Dec 7 '07 #8
Dököll
2,364 Expert 2GB
Removing single quotes? We never said to remove single quotes. You have to do the opposite. In a string with single quotes, you have to double up on the single quotes.

Also, that snippet of code shouldn't throw an error in of itself.
What do you know, I missed the pretty picture "...change all single quotes to double single quotes..."

I see now.

I think I read "...change all single quotes..." and kept on.

Alright, I'll give it another go. Many thanks, gang!

Dököll
Dec 11 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Geoff Cox | last post by:
Hello, One person to date has received a runtime error message saying "parent.frameleft.location is not an object" with the following code. The code is used to select 2 frames at the same...
10
by: DataBard007 | last post by:
Hello Access Gurus: I use Win98SE and Access97. I just built a simple Access97 application which holds all contact information for my personal contacts, such as first name, last name, address,...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
3
by: william | last post by:
Hello Everyone, I'm using Access 2000. I entered the following code to do some data validation, however it is not working. I'm trying to ensure that the user cannot enter a duplicate inspection...
3
by: philelpko | last post by:
Hi all, I have been banging my head against the wall with this one for a while so I now turn to you all for a pointer. I am currently having trouble with error 2448 “You can't assign a value to...
2
by: jr | last post by:
Hello everyone! I am new to this sort of postings so I'm not even sure if this is the correct place to start. Anyway, I would realy appreciate any help. I have a some VBA code that works quite...
1
by: kickergirl | last post by:
I recently created a database in Access 2000 that has been distributed to multiple people using various versions of Access. Each person is using it as a standalone database. The database has...
17
by: trose178 | last post by:
Good day all, I am working on a multi-select list box for a standard question checklist database and I am running into a syntax error in the code that I cannot seem to correct. I will also note...
5
by: rolltide | last post by:
I've seen many similar threads, but despite repeated efforts I cannot figure out my problem. I am running Access 2003, VB 6.5, Office XP Pro. Code excerpt is below (you can see where I've tried...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.