[英]How to refresh value or display the next value of a textbox when button click(saved)
I have a form that will display the next value of the voucher_id in a textbox. 我有一个表单,它将在文本框中显示voucher_id的下一个值。 I am able to do that. 我能够做到。 The problem is when I click the save button, the value of the textbox is the same. 问题是当我单击“保存”按钮时,文本框的值是相同的。 I have to close the form and re-run it to refresh the value of the textbox. 我必须关闭该窗体并重新运行以刷新文本框的值。 Can anyone help me to display the next value after clicking the save button? 单击保存按钮后,谁能帮助我显示下一个值? Here's my code snipet 这是我的代码片段
Private Sub Form_Load()
Dim rcset As New ADODB.Recordset
Dim conConnection As New ADODB.Connection
conConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
App.Path & "\" & "db_finance.mdb;Mode=Read|Write"
conConnection.CursorLocation = adUseClient
conConnection.Open
Set rcset = conConnection.Execute("SELECT Max(voucher_id) FROM voucher")
Text1.Text = rcset(0) + 1
End Sub
Any help would be much appreciated. 任何帮助将非常感激。
Try Like this 像这样尝试
Private Sub NextID()
Dim rcset As New ADODB.Recordset
Dim conConnection As New ADODB.Connection
conConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=" & _
App.Path & "\" & "db_finance.mdb;Mode=Read|Write"
conConnection.CursorLocation = adUseClient
conConnection.Open
Set rcset = conConnection.Execute("SELECT Max(voucher_id) FROM voucher")
Text1.Text = rcset(0) + 1
End Sub
Private Sub Form_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Call NextID()
End Sub
Private Sub Button_Click(Val sender As Object, ByVal e As System.EventArgs)
Handles Button1.Click
'// CAll Save Function - your function to to save
Call NextID()
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.