Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transaction log controltype property problem

Status
Not open for further replies.

mharpe

Technical User
Nov 23, 2007
5
NL
Hi,

I'm also trying to make a changelog.. I have a piece of code that checks if a control on a form is a textfield or a memofield.. I'm using this code for it but the MyCtrl.ControlType results in a numeric value everytime so the statement is False everytime.. Does anyone know why this doesn't work and how I have to check for a memo field..?
Thanks in advance...

Here's the code

'Piece of Michael Red 8/1/2002 Transaction log for Ms. Access BOUND forms.

For Each MyCtrl In Frm.Controls
If (basActiveCtrl(MyCtrl)) Then 'Consider replacing w/ test for "ControlSource"
If ((MyCtrl.Value <> MyCtrl.OldValue) _
Or (IsNull(MyCtrl) And Not IsNull(MyCtrl.OldValue)) _
Or (Not IsNull(MyCtrl) And IsNull(MyCtrl.OldValue))) Then
If (MyCtrl.ControlType = dbMemo) Then
Hist = "tblHistMemo"
Else
Hist = "tblHist"
End If
Debug.Print Hist

Call basAddHist(Hist, Frm.Name, MyKey.Name, MyCtrl)
End If
End If
Next MyCtrl

 
Put the cursor inside the ControlType word in your code and then press the F1 key.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Sorry if i wasn't clear enough...
Hope you can still help me out...
Here is the whole code I used:


My problem is in this piece of the code:
Code:
If (MyCtrl.ControlType = dbMemo) Then
                            Hist = "tblHistMemo"
                        Else
                            Hist = "tblHist"
                    End If

MyCtrl.Controltype has a numeric value and never results in being "=dbMemo" So the code never uses the tblHistMemo to store memo fields..This results in an error if a memo field has more than 255 characters because that can't be stored in a textfield..
 
There is no memo controltype in Access! PHV thought that if you follwed his advice, and read the list of controltypes that you'd see this! Memo fields from Access tables are held in text boxes on forms!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
I know and I did follow his advice and saw that...
But I didn't write this piece of code myself (see link for original code) and I saw any comments with it that it didn't work..And the creator states that it has been tested properly..

What would then be the proper way to make a difference between a textbox that is bound to a textfield in a table and a textbox that is bound to a memofield in a table?
 
How are ya mharpe . . .

If you squeeze in a recordset you can get the type:
Code:
[blue]   Dim MyDb As DAO.Database
   Dim MyCtrl As Control
   Dim MyMsg As String
   Dim Hist As String
   Dim rst As DAO.Recordset
   
   [purple][b]Set rst = frm.RecordsetClone[/b][/purple]
   [green]'
   'Your Code
   '[/green]
   If [purple][b]rst!(ctl.Name).Type[/b][/purple] = dbMemo Then
      Hist = "tblHistMemo"
   Else
      Hist = "tblHist"
   End If
   [green]'
   'Your Code
   '[/green][/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
Thanks for your help Aceman...
I'm new at using VBA to let access to the things I want... so sorry for not being clear when asking questions..

I tried to use the recordset code you gave me but I'm still getting an error. The error is:

"Type declaration character does not match declared data type"

I'm not sure what I'm doing wrong here...
 
Thanks for all your help...
Here's the solution:

This didn't work: If rst!(ctl.Name).Type = dbMemo Then

This works: If rst.Fields(MyCtrl.ControlSource).Type = dbMemo Then

Thanks you all
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top