*help me with this code i cant withdraw.
*the balance inquiry didnt appear in the form4

*in my database, do i need to put the withdraw field?

<form 6>

Imports System.Data.OleDb

Public Class Form6
    Dim conn As OleDbConnection
    Dim cmd As OleDbCommand
    Dim strSQL As String
    Dim dr As OleDbDataReader


    Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Database1.mdb")
        conn.Open()
    End Sub

    Private Sub enter6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles accept6.Click
      
        strSQL = "UPDATE ATM SET Balance_Inquiry = '" & Val(TextBox1.Text) - Val(Form4.balance.Text) & "' WHERE Balance_Inquiry = '" & Form4.balance.Text & "'"
        
        If TextBox1.Text > Form4.balance.Text Then
            MsgBox("Your Balance is insufficient to withdraw")
            TextBox1.Text = ""
            TextBox1.Focus()
        ElseIf TextBox1.Text < Form4.balance.Text Then
            Form4.balance.Text = Form4.balance.Text - TextBox1.Text
            Me.Hide()
            Form8.Timer1.Enabled = True
            Form7.Show()
        End If
        cmd = New OleDbCommand(strSQL, conn)
       
    End Sub

    Private Sub cancel6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cancel6.Click
        Me.Hide()
        Form10.Show()
        Form1.pinenter.Text = ""
    End Sub

    Private Sub clear6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clear6.Click
        TextBox1.Text = ""
        TextBox1.Focus()
    End Sub

Be carefull when comparing. In your code, if TextBox1.Text contains "10" and Form4.balance.Text contains "2", the sentence

If TextBox1.Text > Form4.balance.Text Then

will return false.

Try to change the If or ElseIf using the Val function like you use in the UPDATE statement.

Also use the Val function to do the calculation of the new Form4.balance.Text

Anyway is diffcult to me to figure how Form6 has knowledge about Form1, Form4, Form7, Form8 and Form10.

Hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.