Error 13 Type mismatch (1 Viewer)

Steve2003

Registered User.
Local time
Today, 09:56
Joined
Jun 20, 2003
Messages
16
To one and all,

Thanks in advance for helping me.
I have tried to lookup this answer, using error 13 and type mismatch, but to no avail and am sure it is easy but for the life of me cannot work it out.

I have the following part of code in a module:-

Sub CreateNewTableFromTextboxes(frm As Form)
Dim strRecSource As String
Dim strSqlLeft As String
Dim strsqlRight As String
Dim NameTable As String
Dim StrFields As String
Dim ctl As Control
Dim tdfNew As TableDef



NameTable = "tblMailshot sent " & Format(Date, "dd-mm-yyyy")
NewName:


Set db = CurrentDb

' Create a new TableDef object.
Set tdfNew = db.CreateTableDef(NameTable)

With tdfNew
' Create fields and append them to the new TableDef
' object. This must be done before appending the
' TableDef object to the TableDefs collection of the
' Northwind database.

For Each ctl In frm.Detail.Controls

AVOVE IS WHERE THE CODE FAILS


When I try and call it from a command button with:-

Dim MnFrm As Form
Set MnFrm = Forms(Application.CurrentObjectName)


modCreateTable.CreateNewTableFromTextboxes (Forms(MnFrm).Form)

I get the runtime error 13 message, type mismatch.

What I am trying to do is scan the current form for all the textbox names.
Any help would be much apprciated.

Regards

Steev
 

bat1799

Registered User.
Local time
Today, 09:56
Joined
Nov 18, 2005
Messages
27
You are overcomplicating the call, replace:-
Dim MnFrm As Form
Set MnFrm = Forms(Application.CurrentObjectName)
modCreateTable.CreateNewTableFromTextboxes (Forms(MnFrm).Form)
With:-
Call CreateNewTableFromTextboxes(Me)

HTH

Peter
 

Steve2003

Registered User.
Local time
Today, 09:56
Joined
Jun 20, 2003
Messages
16
Peter,

Many thanks.
Also finally sorted by removing the (frm as form) in the sub and placing

Dim frmName As Form

Set frmName = Forms(Application.Screen.ActiveForm.Name).Form
within the module.

Typical struggle for hours to fix it, post a question, try another way while you are waiting and bang it's fixed.
Sorry for using up your time but many thanks for the reply!!

Steve
 

Users who are viewing this thread

Top Bottom