Question Wonky Variable Passing in Forms

tjonsek

New member
Joined
Apr 22, 2010
Messages
3
Programming Experience
5-10
This is my first Windows app to create since VB6. I've been in the world of ASP and ASP.NET for many years. However, now I have been asked to create a simple app that needs to be windows based.

So far, so good - except when I pass a variable from a datagrid from one form to the next I see a bit of odd behavior. What should be happening is the user clicks on a button within the gridview, to which the ID for that record is bound. The button opens up a form with fields to complete, etc.

What I'm seeing is this: User clicks on a button, form pops up all details there as expected. User closes second form. User clicks on button in datagrid on different cell, form pops up with previous records details. User closes second form, clicks button again and this time sees the expected record in the second form.

This is a very simple app. The datagridview button is the ONLY place where the ID ever changes. It is only used to build a sql statement or two but never manipulated anywhere other than that one piece of code.

Here is the code:

'created a global variable
Module modGlobals
Friend idReminder As Integer = Nothing
End Module

'button selecting record and opening new form
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
idReminder = DataGridView1.CurrentCell.Value

frmReminderDetails.Show()
End Sub

'loading second form
Private Sub frmReminderDetails_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Dim idReminder As Integer = frmRemindersList.btnReminderID.Text
Dim strSql As String = String.Empty
conn.Open()

strSql = "SELECT fname,lname,phone,email,time,reminder,reminder_id FROM vwRemindersTracking WHERE tracking_id =" & idReminder
Dim sql As New SqlCommand(strSql, conn)
sql.CommandType = CommandType.Text
..... more code follows

Any ideas/help is greatly appreciated
 

Latest posts

Back
Top