Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default This is easy for you people!

I have a sheet1 with a lot of numbers and Text, in the module to this sheet i
have a VB code. Depending of what choices the user makes a new form appears.
The form has 3 CmdButtons, called Ok, Next, Cancel. It's like this:

If
ActiveSheet.Range("e" & EnviromentRow).Value="b6"
then

Beep
Load FrmNewInput
FrmNewInput.Show

The form code is like this:
(The code for the Ok button)

Private Sub CmdOk_Click()
''missing something''''
Me.Hide
End Sub

''''And then it should "go back" to the module and something like this:

If FrmNewInput.CmdCancel = True Then '''''If the user press the
cancel button
Exit Sub
ElseIf FrmNewInput.CmdOk = True Then
msgbox
Else FrmNewInput.CmdNext = True then
msgbox
End If

This is not correct i know that, but what is wrong?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default This is easy for you people!


for more control use a variable of class frmNewInput
similar to..

'in a module
Dim uf1 As UserForm1 'use a module level variable.

Sub FormLoader()
If uf1 Is Nothing Then
Set uf1 = New UserForm1
End If
uf1.Show
MsgBox uf1.lngExit & vbLf & uf1.TextBox1 & vbLf & uf1.TextBox2
if uf1.lngExit = -1 then set uf1 = nothing
End Sub


'in a form of class UserForm1
'holds 2 textboxes and 2 commandbuttons
Option Explicit
Public lngExit As Long

Private Sub CommandButton1_Click()
lngExit = 1
Me.Hide
End Sub

Private Sub CommandButton2_Click()
lngExit = -1
Unload Me
End Sub

Private Sub UserForm_Initialize()
Me.TextBox1 = "initial value"
Me.TextBox2 = "initial value"
End Sub


HTH..


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Michael wrote :

I have a sheet1 with a lot of numbers and Text, in the module to this
sheet i have a VB code. Depending of what choices the user makes a
new form appears. The form has 3 CmdButtons, called Ok, Next,
Cancel. It's like this:

If
ActiveSheet.Range("e" & EnviromentRow).Value="b6"
then

Beep
Load FrmNewInput
FrmNewInput.Show

The form code is like this:
(The code for the Ok button)

Private Sub CmdOk_Click()
''missing something''''
Me.Hide
End Sub

''''And then it should "go back" to the module and something like
this:

If FrmNewInput.CmdCancel = True Then '''''If the user press
the cancel button
Exit Sub
ElseIf FrmNewInput.CmdOk = True Then
msgbox
Else FrmNewInput.CmdNext = True then
msgbox
End If

This is not correct i know that, but what is wrong?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default This is easy for you people!


Have a look at this:


Code
-------------------

If ActiveSheet.Range("e" & EnviromentRow).Address="$B$6" then '* I've put address here but if the value is B6 then put it back
Beep
Load FrmNewInput
FrmNewInput.Show
End If

Select Case FrmNewInput.Button_Code
Case FrmNewInput.Cancel
Code here for canceling
Case FrmNewInput.Ok
Code here for ok button
Case FrmNewInput.CmdNext
Code here for next
End Select

-------------------


In your form at module level:


Code
-------------------

Public Const Cancel = 1
Public Const Ok = 2
Public Const CmdNext = 3
'*
Public Button_Code as Integer

Private Sub CmdOk_Click()
Button_Code = Ok
Me.Hide
End Sub

-------------------



Regards

Ric

--
Rich_
-----------------------------------------------------------------------
Rich_z's Profile: http://www.excelforum.com/member.php...fo&userid=2473
View this thread: http://www.excelforum.com/showthread.php?threadid=38426

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default This is easy for you people!

Thanks.
It worked like i hoped.

Thank you again:-)
--
Nil Satis Nisi Optimum


"keepITcool" wrote:


for more control use a variable of class frmNewInput
similar to..

'in a module
Dim uf1 As UserForm1 'use a module level variable.

Sub FormLoader()
If uf1 Is Nothing Then
Set uf1 = New UserForm1
End If
uf1.Show
MsgBox uf1.lngExit & vbLf & uf1.TextBox1 & vbLf & uf1.TextBox2
if uf1.lngExit = -1 then set uf1 = nothing
End Sub


'in a form of class UserForm1
'holds 2 textboxes and 2 commandbuttons
Option Explicit
Public lngExit As Long

Private Sub CommandButton1_Click()
lngExit = 1
Me.Hide
End Sub

Private Sub CommandButton2_Click()
lngExit = -1
Unload Me
End Sub

Private Sub UserForm_Initialize()
Me.TextBox1 = "initial value"
Me.TextBox2 = "initial value"
End Sub


HTH..


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Michael wrote :

I have a sheet1 with a lot of numbers and Text, in the module to this
sheet i have a VB code. Depending of what choices the user makes a
new form appears. The form has 3 CmdButtons, called Ok, Next,
Cancel. It's like this:

If
ActiveSheet.Range("e" & EnviromentRow).Value="b6"
then

Beep
Load FrmNewInput
FrmNewInput.Show

The form code is like this:
(The code for the Ok button)

Private Sub CmdOk_Click()
''missing something''''
Me.Hide
End Sub

''''And then it should "go back" to the module and something like
this:

If FrmNewInput.CmdCancel = True Then '''''If the user press
the cancel button
Exit Sub
ElseIf FrmNewInput.CmdOk = True Then
msgbox
Else FrmNewInput.CmdNext = True then
msgbox
End If

This is not correct i know that, but what is wrong?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how many people are scheduled between... jat Excel Worksheet Functions 0 October 22nd 09 10:39 PM
Need help of you people malik Excel Worksheet Functions 0 February 16th 09 09:13 PM
Need help of you people malik Excel Worksheet Functions 2 February 16th 09 08:06 PM
Why do people use SUM() unnecessarily? [email protected] Excel Discussion (Misc queries) 20 May 20th 06 07:21 PM
new user with easy question? not easy for me speakeztruth New Users to Excel 5 June 3rd 05 09:40 PM


All times are GMT +1. The time now is 12:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"