Paste into ActiveForm Textbox

01-25-2003, 01:51 PM

ive not been here for some time, but ur still the first guys/gals i come to for help regarding VB (been doing otherthings of late, including exams)

My problem is:
i have an MDI program, the child documents have multiple textboxs, comboboxs, and check boxes depending on what they need, the controls are (well... will be) created at run time depending on what the database its loading has as columns. Ill probably need to change the codes and find something different to what im planing, but thats not my problem.

I want to let u user paste text into their selected txt or cbo box by using the file menu or tab menu, but i cant find code that'll let me paste text into a box on the activeform, i can make it specifically paste into a box i hard code, but as the boxes will be dynamic i wont know what box is selected, is there some code like this


that'll work or do i need to find a different way of making it work?


Madtaj (

01-25-2003, 02:12 PM
Screen.ActiveControl.Text = "Hi"
'Attempts to change the active control text to "Hi".

'Gives you the active form.

Screen.ActiveForm.ActiveControl.Caption = "Hi"
'Same as active control.

One of these should be suitable.

Dim Ctl As Control
Set Ctl = Screen.ActiveControl
If TypeOf Ctl Is TextBox Then
Ctl.Text = "Hi"
End If
Set Ctl = Nothing
'edit: Proper way

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum