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
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. - 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]='" & [Surname] & "') AND " & _
-
"([Period_frm]=#" & Format([Period_frm],"M/D/YYYY") & "#))"
- 'stLinkCriteria2 = "[Period_frm]=" & "'" & Me![Period_frm] & "'"
- DoCmd.OpenForm stDocName, , , stLinkCriteria
-
-
Exit_IndividualRpt_Click:
-
Exit Sub
-
-
Err_IndividualRpt_Click:
-
MsgBox Err.Description
-
Resume Exit_IndividualRpt_Click
-
-
End Sub
Try the following modified code.
You had strings in Date fields + some other problems.
Let me know if you want all problems / changes explained. - 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]='" & [Surname] & "') AND " & _
-
"([Period_frm]=#" & Format([Period_frm],"M/D/YYYY") & "#))"
- 'stLinkCriteria2 = "[Period_frm]=" & "'" & Me![Period_frm] & "'"
- DoCmd.OpenForm stDocName, , , stLinkCriteria
-
-
Exit_IndividualRpt_Click:
-
Exit Sub
-
-
Err_IndividualRpt_Click:
-
MsgBox Err.Description
-
Resume Exit_IndividualRpt_Click
-
-
End Sub
Thanks a lot, NeoPa. The code worked nicely after i made the necessary amendments. I appreciate this!!!
NeoPa 32,568
Recognized Expert Moderator MVP
I'm glad to hear it worked for you :).
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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.
|
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
|
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,
| |
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...
|
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...
|
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 ...
|
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%>
|
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,...
|
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...
| |
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,...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |