Question : show record field in textbox

I have a form with 2 text boxes one inputs account number one inputs account name and then based on those values geneates an error or enables or disables 2 labels

what i want to do is to show the client name corresponding to those search inputs in a new text box

for e.g. if a client inputs 001 in the account number text box and searches i want to show the client name that has account number 001 in a text box and do the rest of the calculations
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
Dim rst As DAO.Recordset
Dim bOK As Boolean
Dim i As Integer
Dim sInfo As String
bOK = True
 
If Nz(Me.txtaccno, "") = "" And Nz(Me.txtclientname, "") = "" Then
  MsgBox "You must select a  Trading Account Number or Client Name"
  Exit Sub
End If
Set rst = CurrentDb.OpenRecordset("SELECT * FROM tblcorp WHERE tradingaccno='" & Me.txtaccno & "' OR clientname='" & Me.txtclientname & "'")
If Not rst.EOF Then
rst.MoveLast
rst.MoveFirst
 
Do Until rst.EOF
 If rst("memorandum").Value = False Then
    Label56.Visible = True
    bOK = False
  End If
   
   If rst("boardresolution").Value = False Then
    Label57.Visible = True
    bOK = False
  End If
 
  rst.MoveNext
Loop
 
Else
  MsgBox "Account Number/Client Name not found", vbOKOnly
  Exit Sub
End If
 
If bOK = True Then
  MsgBox "Everything is complete for this Account."
  End If
End Sub
Open in New Window Select All

Answer : show record field in textbox

Use the Afterupdate event procedures of the two textboxes.

Sub txtaccno_afterupdate()
If nz(me.txtaccno,"") >"" then
me.txtclientname = Dlookup("clientname", "tblcorp", "tradingaccno='" & Me.txtaccno &"'")
else
me.txtclientname = ""
end if
End sub

Sub txtclientname_afterupdate()
If nz(me.txtclientname,"") >"" then
me.txtcaccno = Dlookup("tradingaccno", "tblcorp", "clientname='" & Me.txtclientname & "'")
else
me.txtaccno = ""
end if
End sub
Random Solutions  
 
programming4us programming4us