?
Solved

help~

Posted on 2003-02-22
14
Medium Priority
?
133 Views
Last Modified: 2010-05-01
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
Comment
Question by:Barca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 2
  • +1
14 Comments
 
LVL 5

Accepted Solution

by:
JohnMcCann earned 60 total points
ID: 7999764
That should not  be in the loop

DBrstA.MoveFirst
 
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 7999790
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
 
LVL 5

Expert Comment

by:JohnMcCann
ID: 7999798
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
Industry Leaders: 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!

 
LVL 3

Author Comment

by:Barca
ID: 7999807
the problem still not fix
0
 
LVL 3

Author Comment

by:Barca
ID: 7999819
the problem still not fix
0
 
LVL 2

Expert Comment

by:Jacamar
ID: 8000199
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
 
LVL 18

Expert Comment

by:bobbit31
ID: 8000368
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
 
LVL 5

Expert Comment

by:JohnMcCann
ID: 8000641
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
 
LVL 3

Author Comment

by:Barca
ID: 8001095
K_Check is a check box
0
 
LVL 5

Expert Comment

by:JohnMcCann
ID: 8001135
You've lost me

K_Check is a check box

and

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


I assume DBrstA is recorset

0
 
LVL 2

Expert Comment

by:Jacamar
ID: 8001152
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
 
LVL 3

Author Comment

by:Barca
ID: 8001933
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
 
LVL 3

Author Comment

by:Barca
ID: 8001998
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
 
LVL 3

Author Comment

by:Barca
ID: 8002011
thanks to all
i solved all problem now
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question