Manually adding data to a autopopulating text box (1 Viewer)

Kuleesha

Member
Local time
Today, 22:31
Joined
Jul 18, 2021
Messages
50
I have an bound textbox which is set up to autopopulate with data depending on entries in other parts of the same / other forms.

Its coding is as follows:
Code:
txtProblemList = DLookup("Diagnosis", "qryDiagnosis", "PatientID=" & [Forms]![frmPatient]![PatientID]) & " " & Me.txtPastMxHx & " " & Me.txtPastSxHx
txtProblemList = Trim(txtProblemList)

I want to be able to enter new data also into the textbox so that it is saved in the table. Although the data is initially saved, upon exit from the form the manually entered data gets erased and only the auto entered data stays.
Any ideas for a solution?
Thanks
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:01
Joined
May 7, 2009
Messages
19,230
you need only to "auto-fill" txtProblemList when it is "blank"?
Code:
If Len(Me!txtProblemList & "") < 1 then
    txtProblemList = DLookup("Diagnosis", "qryDiagnosis", "PatientID=" & [Forms]![frmPatient]![PatientID]) & " " & Me.txtPastMxHx & " " & Me.txtPastSxHx
    txtProblemList = Trim(txtProblemList)
End If
 

Kuleesha

Member
Local time
Today, 22:31
Joined
Jul 18, 2021
Messages
50
you need only to "auto-fill" txtProblemList when it is "blank"?
Code:
If Len(Me!txtProblemList & "") < 1 then
    txtProblemList = DLookup("Diagnosis", "qryDiagnosis", "PatientID=" & [Forms]![frmPatient]![PatientID]) & " " & Me.txtPastMxHx & " " & Me.txtPastSxHx
    txtProblemList = Trim(txtProblemList)
End If
It needs to autofill even when the field has some manually entered text so that autofill text is added to the manual text.
Is this possible?
 

Gasman

Enthusiastic Amateur
Local time
Today, 18:01
Joined
Sep 21, 2011
Messages
14,259
Why not have a control for 'additional' text and then just append?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:01
Joined
May 7, 2009
Messages
19,230
you just Append the auto-text part?

txtProblemList = (txtProblemList + ";") & DLookup("Diagnosis", "qryDiagnosis", "PatientID=" & [Forms]![frmPatient]![PatientID]) & " " & Me.txtPastMxHx & " " & Me.txtPastSxHx
txtProblemList = Trim(txtProblemList)
 

Gasman

Enthusiastic Amateur
Local time
Today, 18:01
Joined
Sep 21, 2011
Messages
14,259
you just Append the auto-text part?

txtProblemList = (txtProblemList + ";") & DLookup("Diagnosis", "qryDiagnosis", "PatientID=" & [Forms]![frmPatient]![PatientID]) & " " & Me.txtPastMxHx & " " & Me.txtPastSxHx
txtProblemList = Trim(txtProblemList)
Now the O/P is going to say 'No I want the extra text at the end, not the beginning' :)
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:01
Joined
May 7, 2009
Messages
19,230
Now the O/P is going to say 'No I want the extra text at the end, not the beginning'
i believe too, but i was thinking this may be a History of some sort.
so whatever the OP type there is the Latest info, so it should be in
the beginning.:)
 

Kuleesha

Member
Local time
Today, 22:31
Joined
Jul 18, 2021
Messages
50
you just Append the auto-text part?

txtProblemList = (txtProblemList + ";") & DLookup("Diagnosis", "qryDiagnosis", "PatientID=" & [Forms]![frmPatient]![PatientID]) & " " & Me.txtPastMxHx & " " & Me.txtPastSxHx
txtProblemList = Trim(txtProblemList)
I tried this earlier u think but then each time the query is updated the manual text tended to get duplicated. I'm not sure will check again.
I tried without parentheses- would that make a difference ?
And no I don't mind about the order the things are displayed 🙂
 

Gasman

Enthusiastic Amateur
Local time
Today, 18:01
Joined
Sep 21, 2011
Messages
14,259
I tried this earlier u think but then each time the query is updated the manual text tended to get duplicated. I'm not sure will check again.
I tried without parentheses- would that make a difference ?
And no I don't mind about the order the things are displayed 🙂
You are not giving the full picture. :(

Please explain ALL the steps for use of this auto fill value.

I still think a simple extra control is the easiest way to handle this. Only add if something is in the extra control?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:01
Joined
Feb 19, 2002
Messages
43,257
tried this earlier u think but then each time the query is updated the manual text tended to get duplicated.
That is EXACTLY what happens when you concatenate an existing string with something else. As Gasman suggested, we are not mind-readers. Please explain your problem and be sure to include why sometimes you want to concatenate a value and sometimes you don't.

In general, concatenating multiple values in a single field is poor practice since it violates first normal form.
 

Kuleesha

Member
Local time
Today, 22:31
Joined
Jul 18, 2021
Messages
50
Thanks guys. I ended up using an extra control as Gasman suggested.
 

Users who are viewing this thread

Top Bottom