Update unbound TextBoxes on Form; Need to Read AND Write

R

ryguy7272

Learning the ins and outs of Access is a humbling experience.

Anyway, I thought I would update some unbound TextBoxes on a few Forms using
Dlookup. That method seemed to work well. Sometimes I need to simply view
the contents of a Field in a Table, named ‘PatientTable’ and in these cases
the Dlookup works fine.
To view the data in the Field, I am using a method such as this:
=DLookUp("[SIM_Comments]","[PatientTable]","[MR] = " & [MR])

However, sometimes I have to view the contents of this field, and sometimes
I have to add to the Field; I need read a write access to the Table. What is
the easiest way to do this? The DLookUp() seems to prevent me from writing
back to the Table.

I have been trying to load the appropriate variables from the Field with
this code:
Private Sub Command20_Click()
Me.Form.RecordSource = "SELECT * FROM SimQuery " & BuildFilterSim
Me.SimForm.Requery
End Sub

Private Function BuildFilterSim() As Variant
Dim varWhere As Variant
Dim varItem As Variant
Dim intIndex As Integer
varWhere = Null ' Main filter
' Check for LIKE First Name
If Me.MR > "" Then
varWhere = varWhere & "[MR] LIKE """ & Me.MR & "*"" AND "
End If
' Check if there is a filter to return...
If IsNull(varWhere) Then
varWhere = ""
End If
BuildFilter = varWhere
End Function

The Field named ‘MR’ is a uniqe ID number and I believe could be looked up
according to this. Is this approach correct? How can I get this working?

Thanks,
Ryan----
 
R

ryguy7272

Just discovered a much easier way to do this...

I have a TextBox named 'MR'. In the 'AfterUpdate' event I popped in this
code:
Private Sub MR_AfterUpdate()
Me.SIM_Comments = DLookup("[SIM_Comments]", "[PatientTable]", "[MR] = "
& [MR])
End Sub

Now my TextBox named 'SIM_Comments' updates effortlessly.

Problem solved!!

Thanks,
Ryan---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top