ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Tricky user form question (https://www.excelbanter.com/excel-programming/306070-tricky-user-form-question.html)

nath

Tricky user form question
 
HI All,

I have an excel spreadsheet that is used as a tool to
enter data into a heavily administered database.

I have a user form that is built from the table within
access that the data is eventually transferred to. How
ever:

The fields in this table are subject to change so the
table builds based on what is in the table and the text
boxes are labeled accordingly.

I have done this and the code/form works fine.

Now i need to have a macro called when the user enters one
of these textboxes. For example, the code will create a
text box and call it the same as the field in the access
table where the data will eventually go, ie.
txtDate_of_Birth, i need to work out how to put the
txt_Date_of_Birth_Enter() code in, when the name of the
text box may change.

Can this be done.

Nath

Jim Rech

Tricky user form question
 
Yes, I think it can be done. Here's start:

Sub a()
Dim LineNum As Integer
With ThisWorkbook.VBProject.VBComponents("Userform1")
.Designer.Controls.Add "Forms.TextBox.1", "MyTB"
LineNum = .CodeModule.CreateEventProc("Enter", "MyTB")
.CodeModule.InsertLines LineNum + 1, "Beep"
End With
End Sub


--
Jim Rech
Excel MVP




All times are GMT +1. The time now is 06:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com