All,
I am getting "Runtime Error 13 Type Mismatch" when the subroutine immediately below executes. frmProducts is the form name and the NewRecordMark sub is shown below. I have tried several ways of passing the form to NewRecordMark and none have worked.
I am new to Access and have much to learn. I will appreciate any help you can give me on this.
Thanks,
Charles
---------------------------------------------------------------------
Private Sub Form_Current()
NewRecordMark (Forms!frmProducts)
End Sub
---------------------------------------------------------------------
Sub NewRecordMark(frm As Form)
Dim intnewrec As Integer
intnewrec = frm.NewRecord
If intnewrec = True Then
MsgBox "You're in a new record." _
& "@Do you want to add new data?" _
& "@If not, move to an existing record."
End If
End Sub
---------------------------------------------------------------------
eliascm
View Public Profile
Send a private message to eliascm
Find all posts by eliascm
#2 01-09-08, 23:19
pkstormy
Moderator Join Date: Dec 2004
Location: Madison, WI
Posts: 2,800
You could try "Variant" instead of "Form" for: Sub NewRecordMark(frm As Variant). <--- changed to variant
Otherwise "I'm guessing" you could try something like this when calling the function NewRecordMark("SomeStrgingRepresetingWhatsBeingSen t") <-just try it in "".
__________________
Expert Database Programming
MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)
--------------------------------------------------------------------------------
Last edited by pkstormy : 01-09-08 at 23:28.
pkstormy
View Public Profile
Send a private message to pkstormy
Find all posts by pkstormy
#3 01-10-08, 15:07
georgev
SQL Apprentice Join Date: Jan 2007
Location: It's relative
Posts: 7,833
I suggest you use
Code:
Sub NewRecordMark(frm As String)
forms(frm).NewRecord__________________
George
I'd like to offer moral support, but I have questionable morals...
georgev
View Public Profile
Send a private message to georgev
Send email to georgev
Find all posts by georgev
#4 01-10-08, 16:01
DCKunkle
Registered User Join Date: Feb 2004
Location: Chicago, IL
Posts: 1,062
The error is being caused by your call to NewRecordMark. NewRecordMark is a Sub and not a Function. A function returns a value and a Sub does not. You are calling NewRecordMark like it is a function and it is trying to return a value, but you are not assigning that value to anything.
Change the line:
NewRecordMark (Forms!frmProducts)
To:
NewRecordMark Forms!frmProducts
When you include the () it is interpreted as a function returning a value. A good example is Date() which returns the current date. You can also call a function with () but precede it with the Call reserved word. That will run the function and throw out the returned value.
DCKunkle
View Public Profile
Send a private message to DCKunkle
Send email to DCKunkle
Find all posts by DCKunkle
#5 01-10-08, 17:22
georgev
SQL Apprentice Join Date: Jan 2007
Location: It's relative
Posts: 7,833
Now why the chuffing hell didn't I notice that!
Good catch DCK
__________________
George
I'd like to offer moral support, but I have questionable morals...
Thursday, December 4, 2008
Subscribe to:
Post Comments (Atom)
1 comment:
I think that you may be interested in another application that quickly eliminates data corruption issues in database files, please take a look at third-party repair utility for visual foxpro tables tool and let me know what do you think
Post a Comment