Simple msgbox question

systemx

Registered User.
Local time
Today, 14:41
Joined
Mar 28, 2006
Messages
107
Hi all,

I have created a simple feedback form in Access...but am having a couple of problems. As a complete Access/VBA newbie I'm not sure what is going wrong....

There is a cbo for 'Category' - and if a category is not selected I would like a msgbox to pop up prompting the user to select one.

For some reason this is not working with the code below....can anyone offer a suggestion as to why?

Private Sub cmd_Submit_Click()

Dim rs As ADODB.Recordset

Set rs = New ADODB.Recordset
rs.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source= C:\..............;"
rs.Open "tblFeedback", , adOpenKeyset, adLockOptimistic, adCmdTable

If Me.txt_name.Visible = True Then

If Me.cbo_category.Value = Null Then
Msgbox "Please select a category", vbokonly, "Category not selected"
Me.cbo_category.SetFocus

With rs
.AddNew
.Fields("Category") = Me.cbo_category.Value
.Fields("Feedback") = Me.txt_feedback.Value
.Fields("Name") = Me.txt_name.Value
.Update
End With

End If


If Me.txt_name.Visible = False Then

With rs
.AddNew
.Fields("Category") = Me.cbo_category.Value
.Fields("Feedback") = Me.txt_feedback.Value
.Fields("Name") = "Anonymous"
.Update
End With

End If
End If

rs.Close
Set rs = Nothing

Me.cbo_category.Value = Null
Me.txt_feedback.Value = Null
Me.txt_name.Value = Null

Me.txt_name.Visible = True
Me.lbl_or.Visible = True

MsgBox "Thank you. Your feedback has been submitted", vbOKOnly, "Feedback Received"

End Sub
 
Hi,
I haven't looked at all of your code, and I really don't know about using the ADODB stuff, but instead of:

If Me.cbo_category.Value = Null Then

try:

if isnull(me.cbo_category) then

hth,
 
Thanks :)

It worked for me...also had to shuffle some of the End If's around and move the 'add' code to another sub -but working perfectly now :)

Rob
 
I'm glad to hear it. Good job figuring it out.
 

Users who are viewing this thread

Back
Top Bottom