473,505 Members | 14,394 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_Click()
On Error GoTo Err_Command12_Click

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_IndividualRpt_Click:
Exit Sub

Err_IndividualRpt_Click:
MsgBox Err.Description
Resume Exit_IndividualRpt_Click

End Sub
Nov 23 '06 #1
3 3552
NeoPa
32,557 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,557 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
2477
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...
0
2230
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...
1
4571
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...
6
5973
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...
1
1650
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...
2
5574
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...
1
2804
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...
4
5683
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,...
7
4428
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...
0
7216
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
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
7303
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,...
1
7018
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...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4699
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...
0
1528
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 ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.