VB School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Add Popmenu Code for Add button Rate Topic: -----

#1 van01  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 17-January 08


Dream Kudos: 0

Share |

Add Popmenu Code for Add button

Post icon  Posted 17 January 2008 - 01:53 PM

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.


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
Was This Post Helpful? 0
  • +
  • -


#2 LookNAO  Icon User is offline

  • D.I.C Head
  • PipPip

Reputation: 2
  • View blog
  • Posts: 66
  • Joined: 28-December 07


Dream Kudos: 0

Re: Add Popmenu Code for Add button

Posted 21 January 2008 - 05:57 AM

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.
Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users