Typs are incompatible, Controls

Slangly

New Member
Joined
Dec 4, 2005
Messages
2
Hi everybody!
First I have to say that I´m from Austria, so I hope you understand that my English is not perfect. So please keep your answers in an understanding form. Thanks

Now my problem:

I want to dis/enable some textboxes. I use the selfwritten function ButtonsPerson. When I start my form, I get the runtime error number 13, "Typs are incompatible".

Here are some parts of my code, which should be enough for you guys, to recognize the problem.

Thank you again.

Slangly

Code:
(global:)
Option Explicit
Option Compare Database
Dim rsFirma As New ADODB.Recordset
Dim rsPerson As New ADODB.Recordset
Dim cn As New ADODB.Connection


Private Sub Form_Load()
    Set cn = CurrentProject.Connection
    rsFirma.Open "firma", cn, adOpenStatic, adLockOptimistic, adCmdTableDirect
    rsPerson.Open "person", cn, adOpenStatic, adLockOptimistic, adCmdTableDirect
    rsFirma.Index = "PrimaryKey"
    rsPerson.Index = "PrimaryKey"
    DatenFirma
    DatenPerson
End Sub

Private Function ButtonsPerson(ByVal Modus As String)
Dim Feld As Field
Dim Name As String
    If (Modus = "Sperren") Then
        For Each Feld In rsPerson.Fields
            Name = "txtP" & Feld.Name
            Forms("firma").Controls(Name).Enabled = False
        Next
    End If
    If (Modus = "Freigeben") Then
        For Each Feld In rsPerson.Fields
            Name = "txtP" & Feld.Name
            Forms("firma").Controls(Name).Enabled = True
        Next
    End If
End Function
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Where is the error occurring?
 
Upvote 0
I realized, that the error is occuring in the for each statement, also when I don´t write anything in the for each.
the type "field" must be false for recordset fields, but which type is the right one?
 
Upvote 0
I see here that you have qualified various things as being ADODB objects, perhaps you also need to do this when declaring Feld.
Code:
Dim rsFirma As New ADODB.Recordset 
Dim rsPerson As New ADODB.Recordset 
Dim cn As New ADODB.Connection
 
Upvote 0

Forum statistics

Threads
1,214,912
Messages
6,122,204
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top