hello everyone,
i need help,
can anyone help me to check out the coding??

Private Sub cmdBatal_Click()
paparan.Show
Me.Hide
Unload Me

End Sub

Private Sub cmdSimpan_Click(Index As Integer)
If InsuData = True Then
con.Execute "Insert into Pemilik(Na,Nokad,Warganegara,Notel,Harga,Tingkat) values ('" & txtNama.Text & "','" & txtNoKad.Text & "', '" & txtWarganegara.Text & "'," & txtNoTel & ",'" & txtTingkat.Text & "')"
  
  MsgBox "Successfuly Save!!", vbInformation, "sistem pengurusan rumah sewa"
  
 End If
End Sub


Function InsuData() As Boolean
Dim ss
 For Each ss In Me
  If TypeOf ss Is TextBox Or TypeOf ss Is ComboBox Then
  If ss.Text = "" Then
      answer = MsgBox("Insufficient Data!", vbInformation, "sistem pengurusan rumah sewa")
      ss.SetFocus
      Exit Function
      End If
     End If
  Next
    InsuData = True
End Function

my module coding :

Global con Asmy module coding : New ADODB.Connection
Sub main()
con.CursorLocation = adUseClient
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\sistempengurusanrumahsewa.mdb;Persist Security Info=False"
login.Show
End Sub

Recommended Answers

All 7 Replies

Is this VB (4,5,6) or VBA (dont really know what is VBA ;)

I think there's no code as "Insert Into" in VB ( at line 10).

Looks like Php to me.

Try this:

Dim rs as New ADODB.Recordset

With rs

.Open "select * from Pemilik", Dbconn, adOpenDynamic, adLockOptimistic
        
        .AddNew
            
      

            .Fields(1) = txtNa.Text	'you can also put the name of the field in your table inside the ()
            .Fields(2) = txtNokad.Text	'i prefer using numbers for easy coding
            .Fields(3) = txtWarganegara.Text
            .Fields(4) = Notel.Text
	    .Fields(1) = txtHarga.Text
            .Fields(2) = txtTingkat.Text

            
            
        .Update
            MsgBox "Record successfully saved!!", vbInformation
        
            .Close

End If

And concatenation in VB if you are going to put 2 or more textbox values in a single field in your Database:

.Fields(1) = .Fields(1) = txtNa.Text & " " & txtNokad.Text & " " & txtWarganegara.Text

Hope this helps.

thanks abelingaw,

im getting error: compile error End if without block if.

Private Sub cmdSimpan_Click(Index As Integer)


Dim rs As New ADODB.Recordset
With rs
 .Open "select * from Pemilik", Dbconn, adOpenDynamic, adLockOptimistic
.AddNew
            .Fields(Na) = txtNa.Text   'you can also put the name of the field in your table inside the ()
            .Fields(Nokad) = txtNoKad.Text  'i prefer using numbers for easy coding
            .Fields(Warganegara) = txtWarganegara.Text
            .Fields(Notel) = Notel.Text
            .Fields(Harga) = txtHarga.Text
            .Fields(Tingkat) = txtTingkat.Text
  
 .Update
            MsgBox "Record successfully saved!!", vbInformation
 
            .Close
 
End If
End Sub

:( can u help me again? thanks..

My fault.

Change End If on Line 20 with End With

thanks, it works! :)

do u know "edit" coding??

Your welcom brotha.

Please mark thread as solve if your problem was solved.

Start new thread if you have another concern.

okay thanks.
:)

Please mark thread as Solve..

Thanks

commented: First solution, well done! +4
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.