Restricting fields

B

Bill

A couple questions that I don't know where to post.

1. I want to create a combo box that is not active until a combo box before
it is choosen. For example. Combo box 1 contains departments. If you
choose the department "Food and Beverage" I want the next combo box to become
active and populate with the sub-departments within the one choosen.

2. When the user changes the form from "Active" to "Closed" I want to
require a comment field and send an email. I have the email being sent now,
so I can arrange that.

I cross posted this under programming also as I was not sure where to put
it. THANKS!
 
J

John W. Vinson

A couple questions that I don't know where to post.

1. I want to create a combo box that is not active until a combo box before
it is choosen. For example. Combo box 1 contains departments. If you
choose the department "Food and Beverage" I want the next combo box to become
active and populate with the sub-departments within the one choosen.

You'll need a couple of bits of code. In the AfterUpdate event of the
Department combo box, put code like

Private Sub cboDepartment_AfterUpdate()
Dim strSQL As String
If Not IsNull(Me!cboDepartment) Then
strSQL = "SELECT Subdepartment FROM tablename " _
& "WHERE Department = '" & Me!cboDepartment & "'"
Me!cboSubdepartment.Enabled = True
Me!cboSubdepartment.RowSource = strSQL
Else
Me!cboSubdepartment.Enabled = False
Me!cboSubdepartment.RowSource = ""
End If
End Sub

with similar code in the Form's Current event to set the rowsource of the
subdepartment combo for existing records.
2. When the user changes the form from "Active" to "Closed" I want to
require a comment field and send an email. I have the email being sent now,
so I can arrange that.

Use the Form's BeforeUpdate event:

Private Sub Form_BeforeUpdate(Cancel as Integer)
If Me!controlname = "Closed" Then
If Me!memofieldcontrol & "" = "" Then
MsgBox "Please fill in comment", vbOKOnly
Cancel = True
Me!memofieldcontrol.SetFocus
Else
<send your email here>
End If
End Sub
I cross posted this under programming also as I was not sure where to put
it. THANKS!

Well... crossposting would have been appropriate, but you "multiposted" -
posting two separate, independent messages. To crosspost you need to include
both newsgroups in the To: line. I don't recall how it's done on the web
interface but there's a tool to do it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top