Database (1 Viewer)

Checkbox

  • Automatic checkbox

    Votes: 0 0.0%
  • Checkbox

    Votes: 0 0.0%
  • Onchange

    Votes: 0 0.0%
  • Onenter

    Votes: 0 0.0%

  • Total voters
    0
  • Poll closed .

Salihu

New member
Local time
Yesterday, 22:47
Joined
Dec 30, 2018
Messages
4
Hello, I am new to access, please I need help. I want a table with beneficiaries details with names and ID and a checkbox , I have added a search button on the form but I want if I search my checkbox automatically checkeck yes if the record if found. Please help.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:47
Joined
May 7, 2009
Messages
19,233
what command/macro do you use for your search?
 

Salihu

New member
Local time
Yesterday, 22:47
Joined
Dec 30, 2018
Messages
4
thanks for you response. Below is the vb i am using,it searches for records and checks check box to yes,but i need it to save the record found in another table if record is found or simply update the tables checkbox so that i can print or use it for analysis.
thank you.

Private Sub Command8_Click()
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("table1")
Dim x As Integer
x = 0
While rs.EOF = False
If rs!ID = Val(Text0) Then
Text4 = rs!beneficiary
Text6 = rs!age
Check9 = True
x = 1
End If
rs.Move 1
Wend
If x = 1 Then
MsgBox ("found")
Else: MsgBox ("not found")
End If
End Sub
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:47
Joined
May 7, 2009
Messages
19,233
i slightly modify your code:
Code:
Private Sub Command8_Click()
	With Currentdb.OpenRecordset("SELECT table1.* FROM table1 WHERE [ID] = " & Val([Text0]))
		If .RecordCount > 0 Then
			[Check9]=True
			.MoveFirst

			[Text4]=!Beneficiary
			[Text6]=!Age

			Msgbox "Found"
		Else 
			Msgbox "Not Found"
			If [Check9]=True Then [Check9]=False
		End If
	End With
End Sub
 

Salihu

New member
Local time
Yesterday, 22:47
Joined
Dec 30, 2018
Messages
4
Thank you so much, but the code returns an error
If .Recordsetcount > 0 then
Please help.
Thanks.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 06:47
Joined
Jul 9, 2003
Messages
16,280
Is the problem a spelling mistake?

Code:
'arnelgp
If .RecordCount > 0 Then

'Salihu
If .Recordsetcount > 0 then
 

Salihu

New member
Local time
Yesterday, 22:47
Joined
Dec 30, 2018
Messages
4
Yes it was a mistake, thanks so much, it's a modified version of the code, but I can't still save the search results or update the table's checkbox column. Is there anyway around this?
Thanks.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:47
Joined
May 7, 2009
Messages
19,233
it will not save if the form is unbound.
you need to create an update query to update the table.
if you could upliad your db we'll take a look and see what is going on.
 

Users who are viewing this thread

Top Bottom