• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 134
  • Last Modified:

help~

i want to check what K_Check value(true/false) is.
if K_Check = false
show ID and Quality in richtextbox
what's wrong of my code?

and how to make a newline in richtextbox?

Private Sub cmdReload_Click()
    Do While Not DBrstA.EOF
        DBrstA.MoveFirst
        If DBrstA.Fields("[K_Check]").Value = False Then
            rtbOrder.Text = rtbOrder.Text + "ID" + DBrstA.Fields("[ID]").Value + "Quality" + DBrstA.Fields("[Quality]").Value
            DBrstA.Fields("[K_Check]").Value = True
        End If
        DBrstA.MoveNext
    Loop
End Sub
0
Barca
Asked:
Barca
  • 6
  • 4
  • 2
  • +1
1 Solution
 
JohnMcCannCommented:
That should not  be in the loop

DBrstA.MoveFirst
 
0
 
bobbit31Commented:
add the vbCrLF Character...(oh and btw, string concatenation is done w/ the & operator, not +)

rtbOrder.Text = rtbOrder.Text & "TableID" & DBrstA.Fields("[Id]").Value & "Quality" & DBrstA.Fields("[Quality]").Value & vbCrLf
0
 
JohnMcCannCommented:
Your code should look something like this

Private Sub cmdReload_Click()
 DBrstA.MoveFirst
 Do While Not DBrstA.EOF
  If DBrstA.Fields("[K_Check]").Value = False Then
   
   rtbOrder.Text = rtbOrder.Text & "ID = "
   rtbOrder.Text = rtbOrder.Text & DBrstA.Fields("[ID]").Value & vbTab

   rtbOrder.Text = rtbOrder.Text & "Quality = " 
   rtbOrder.Text = rtbOrder.Text & DBrstA.Fields("[Quality]").Value & vbCr

   DBrstA.Fields("[K_Check]").Value = True
  End If
  DBrstA.MoveNext
 Loop
End Sub
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
BarcaAuthor Commented:
the problem still not fix
0
 
BarcaAuthor Commented:
the problem still not fix
0
 
JacamarCommented:
to check the value of your textbox do this.

Dim BoolCheck As Boolean

Private Sub Check1_Click()
If Check1.Value = vbChecked Then
BoolCheck = True
End If

If Check1.Value = vbUnchecked Then
BoolCheck = False
End If

End Sub

Private Sub Command1_Click()
If BoolCheck = True Then
    'Code
End If

If BoolCheck = False Then
    'Code
End If
End Sub
0
 
bobbit31Commented:
what is the field type of [K_Check].

if string, then
If DBrstA.Fields("[K_Check]").Value = "False" Then

and what's the error message you are getting if any?
0
 
JohnMcCannCommented:
Is the problem nothing happens

Then it may be the field type of K_Check is not returning a value.

If K_Check is not updating you may ned to add an update statement.

DBrstA.Fields("[K_Check]").Value = True
DBrstA.update
 

If you are still stuck

add this statement

debug.print DBrstA.Fields("[K_Check]").Value

before this one

If DBrstA.Fields("[K_Check]").Value = False Then

Run the code
Go to the debug window (Ctrl + G) read the value of K_Check.

and post it
0
 
BarcaAuthor Commented:
K_Check is a check box
0
 
JohnMcCannCommented:
You've lost me

K_Check is a check box

and

DBrstA.Fields("[K_Check]").Value


I assume DBrstA is recorset

0
 
JacamarCommented:
to check the value of your textbox do this.

Dim BoolCheck As Boolean

Private Sub Check1_Click()
If K_Check.Value = vbChecked Then
BoolCheck = True
End If

If K_Check.Value = vbUnchecked Then
BoolCheck = False
End If

End Sub

Private Sub Command1_Click()
If BoolCheck = True Then
   'Do whatever you want on true  
End If

If BoolCheck = False Then
   'Do whatever you want on false
End If

End Sub
0
 
BarcaAuthor Commented:
the error is can't find the object

"object required"

but i am sure the name of field is true and the type is checkbox in DB(MS access).
0
 
BarcaAuthor Commented:
i know where is my problem now


DBrstA.Fields("[K_Check]").Value

should be
DBrstA.Fields("K_Check").Value


the richtextbox still can't show another record in a new line ~
0
 
BarcaAuthor Commented:
thanks to all
i solved all problem now
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 6
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now