473,657 Members | 2,489 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Keep getting a type mismatch error...why?

3 New Member
The following VBA code, in Access 2003, is to make a button open and populate a form based on the Surname and Period_frm data on a previous form. However, i keep getting a type mismatch error whenever i click the button. I've tried changing the stLinkCriteria2 type to String but the same thing happens. Does anyone know why?

Private Sub IndividualRpt_C lick()
On Error GoTo Err_Command12_C lick

Dim stDocName As String
Dim stLinkCriteria As String
Dim stLinkCriteria2 As Date

stDocName = "View report per individual"

stLinkCriteria = "[Surname]=" & "'" & Me![Surname] & "'"
stLinkCriteria2 = "[Period_frm]=" & "'" & Me![Period_frm] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria And stLinkCriteria2

Exit_Individual Rpt_Click:
Exit Sub

Err_IndividualR pt_Click:
MsgBox Err.Description
Resume Exit_Individual Rpt_Click

End Sub
Nov 23 '06 #1
3 3562
NeoPa
32,568 Recognized Expert Moderator MVP
Try the following modified code.
You had strings in Date fields + some other problems.
Let me know if you want all problems / changes explained.
Expand|Select|Wrap|Line Numbers
  1. Private Sub IndividualRpt_Click()
  2. On Error GoTo Err_Command12_Click
  3.  
  4. Dim stDocName As String
  5. Dim stLinkCriteria As String
  6. 'Dim stLinkCriteria2 As Date
  7.  
  8. stDocName = "View report per individual"
  9.  
  10. stLinkCriteria = "(([Surname]='" & [Surname]  & "') AND " & _
  11.     "([Period_frm]=#" & Format([Period_frm],"M/D/YYYY") & "#))"
  12. 'stLinkCriteria2 = "[Period_frm]=" & "'" & Me![Period_frm] & "'"
  13. DoCmd.OpenForm stDocName, , , stLinkCriteria
  14.  
  15. Exit_IndividualRpt_Click:
  16. Exit Sub
  17.  
  18. Err_IndividualRpt_Click:
  19. MsgBox Err.Description
  20. Resume Exit_IndividualRpt_Click
  21.  
  22. End Sub
Nov 23 '06 #2
emmaruwa
3 New Member
Try the following modified code.
You had strings in Date fields + some other problems.
Let me know if you want all problems / changes explained.
Expand|Select|Wrap|Line Numbers
  1. Private Sub IndividualRpt_Click()
  2. On Error GoTo Err_Command12_Click
  3.  
  4. Dim stDocName As String
  5. Dim stLinkCriteria As String
  6. 'Dim stLinkCriteria2 As Date
  7.  
  8. stDocName = "View report per individual"
  9.  
  10. stLinkCriteria = "(([Surname]='" & [Surname]  & "') AND " & _
  11.     "([Period_frm]=#" & Format([Period_frm],"M/D/YYYY") & "#))"
  12. 'stLinkCriteria2 = "[Period_frm]=" & "'" & Me![Period_frm] & "'"
  13. DoCmd.OpenForm stDocName, , , stLinkCriteria
  14.  
  15. Exit_IndividualRpt_Click:
  16. Exit Sub
  17.  
  18. Err_IndividualRpt_Click:
  19. MsgBox Err.Description
  20. Resume Exit_IndividualRpt_Click
  21.  
  22. End Sub

Thanks a lot, NeoPa. The code worked nicely after i made the necessary amendments. I appreciate this!!!
Nov 24 '06 #3
NeoPa
32,568 Recognized Expert Moderator MVP
I'm glad to hear it worked for you :).
Nov 24 '06 #4

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

Similar topics

1
2488
by: LJgrnl | last post by:
I've got a type mismatch error that's driving me nutty. Variable blnNoData has the initial value False. If a recordset comes back empty (both .EOF and ..BOF are true) then blnNoData is set to True. I then have an if statement to determine what to write to the screen depending on blnNoData. As long as the if statement is true (doesn't have to go to the else clause), the code runs fine. Otherwise, a type mismatch error is returned. In...
0
2246
by: news.paradise.net.nz | last post by:
I have been developing access databases for over 5 years. I have a large database and I have struck this problem with it before but can find nothing in help or online. Access 2000 I have a query that will run fine without any criteria but as soon as I add any criteria it gives a "Data type mismatch" error. As soon as I remove any criteria it runs perfectly. I know this query is based on another query but I have other processes based on...
1
4604
by: MovnOn | last post by:
I'm writing a program that uses a COM object. If I were writing this code in VB6, the signature of the method of the COM object I need to use would be: saveMemo (Collection) The method takes a collection as the parameter. I did a tblimp (I get the same results if I add the COM object as a reference) on the COM object and when I use this in .NET, the same method has a signature of: saveMemo (Object) and the Object is passed ByRef.
6
5984
by: Howard Kaikow | last post by:
I'm doing a VB 6 project in which I am trying to protect against type mismatch errors. Is the process any different in VB .NET? Here's what I'm doing in VB 6. I have an ActiveX DLL. The class has stuff initialized by calling a sub SetClass that wants some Word specific objects passed-in. If the user mistakingly uses the wrong object, say, uses an Excel object
1
1663
by: jodyblau | last post by:
I have a database which works fine until I create and MDE file. Once I create the MDE, when I open a particular form I get a "Type Mismatch" error. Because its an MDE file, I can't step through the code to find out where the error is occuring; and (as I mentioned earlier) when I go back to the oriignal database the problem doesn't exist. Any ideas of what is going on here and how to fix it? Thanks,
2
5588
DonRayner
by: DonRayner | last post by:
This one has me stumped. I'm getting a "Type Mismatch" error on one of my forms when it's being opened. It's hapening before the forms "On Open" event, I stuck a msgbox in there to check and I'm getting the error before it opens. The line of code that calls the form from another form is. DoCmd.OpenForm "NonConformanceAdd",,,,acFormAdd,acDialog I get the error, click ok, then the form opens and works exactly how it's supposed to. I even...
1
2831
by: nckinfutz | last post by:
hello, I am having a problem with an access database. this is not my database and I did not create it, nor am I very good at access. however, I am a network engineer and that is why this problem has ended up in my lap i guess. This is the issue: There is an access database that pulls data from a list of excel spread sheets. This access database and excel files are stored on a server. When the database requests info from the excel file...
4
5704
by: imaloner | last post by:
I am posting two threads because I have two different problems, but both have the same background information. Common Background Information: I am trying to rebuild code for a working, commercially sold application with only partial build instructions. The previous maintainer of the code (a mixture of C and C++) is no longer with the company, but when he built the code he used MSVC++, and though I am not certain of the version he was ...
7
4435
vikas251074
by: vikas251074 | last post by:
I am getting error above in following code since few days giving tension day and night. How can I solve this? I am facing since Oct.25. in line no. 362 After doing a lot of homework, I am surrendered to you. <%@ Language=VBScript%> <%Option Explicit%>
0
8305
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7320
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1944
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.