Welcome to Dream.In.Code
Become a VB Expert!

Join 149,902 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,206 people online right now. Registration is fast and FREE... Join Now!




Add Popmenu Code for Add button

 
Reply to this topicStart new topic

Add Popmenu Code for Add button

van01
17 Jan, 2008 - 01:53 PM
Post #1

New D.I.C Head
*

Joined: 17 Jan, 2008
Posts: 3

Hi



Can anyone help me? I am using a popup menu and would like to add data from the form into mysql database when I click the save button. I am using visual basic 6 with mysql version 5.0. This is the code below. Visual basic complains about the save item on the code line 'Adodc1.Recordset.Addnew. I get the error message "Cannot jump to 'AddNew' because it is hidden" However I use the same line of code to update fields in the modify command and that works fine.


CODE

Private Sub Command2_Click()

If Command2.Caption = "Options" Then
    PopupMenu mnuPopup, 1, (Command2.Left), (Command2.Top + Command2.Height), mnuAdd
ElseIf Command2.Caption = "Modify" Then
    Call ModifyItem
ElseIf Command2.Caption = "Save" Then
    Call SaveItem
End If
End Sub





Private Sub mnuAdd_Click()
Command2.Caption = "Save"
    Call SaveItem

End Sub



Private Sub SaveItem()



If txtFields(15) = "" Then
    MsgBox "Application ID Should Not Be Blank", , "ApplicationID"
        
End If

  Adodc1.Recordset.AddNew

  Exit Sub
End Sub



Modify Command.





Private Sub mnuModify_Click()
Command2.Caption = "Modify"

End Sub



Private Sub ModifyItem()
If txtFields(1) = "" Then Exit Sub

Adodc1.Recordset.UpdateBatch
MsgBox "Details Modified Successfully.", , "Modify"
Command2.Caption = "Options"
  
End Sub




Regards


Vanita
User is offlineProfile CardPM
+Quote Post

LookNAO
RE: Add Popmenu Code For Add Button
21 Jan, 2008 - 05:57 AM
Post #2

D.I.C Head
**

Joined: 28 Dec, 2007
Posts: 66



Thanked: 1 times
My Contributions

You have have the Addnew right...

retype the line Adodc1.Recordset.AddNew and hit space, VB will prompt you what it needs;

Fieldlist, values

Basically, you have to let the code know what it is adding.

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 01:17PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month