pop up form updating multiple text boxes in master form

  • Thread starter Thread starter grizfan
  • Start date Start date
G

grizfan

Guest
I have a master form (frmInspection) with multiple "defect" text boxes for different components on power poles. On click of each "defect" text box a pop-up form (frmDefects) appears with a list box containing 43 defects associated with the whole utility structure. Currently, my code will insert the id(s) of the defect(s) chosen into the text box that i specify (txtPoleDefect) separated by commas.

My problem is that i don't want to populate a specific text box, i want to populate the active textbox that what clicked on the master form. Below is my current code when "cmdSave" is clicked on "frmDefects":

Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click

Dim I As Variant
Dim stNumber As String
Dim stComma As String

stNumber = "": stComma = ","

For Each I In Me!lstDefects.ItemsSelected
stNumber = stNumber & Me!lstDefects.ItemData(I)
stNumber = stNumber & stComma

Next I
stNumber = CStr(Left$(stNumber, Len(stNumber) - Len(stComma)))

Forms.frmInspection.txtPoleDefect = stNumber

DoCmd.Close

Exit_cmdSave_Click:
Exit Sub

Err_cmdSave_Click:
MsgBox Err.Description
Resume Exit_cmdSave_Click

End Sub


Any help is greatly appreciated.
 
more info...

I am assuming you are using this code on your second form.

1. are you closeing your first form befor gong to the second form or you are setting visible = false. preference visible = false, and on exit second form you can set [forms]![form1].visible=true.

2. I am using plenty of second form like you are and I think i have it where it copies the some kinda id from the first form. I have two text box, one is set to unbound "=[forms]![form1]![fieldid]" and lets say the name for this text box is "txtCopyID". This text box is set visible = no.

I have another text with bound to id of the second form (tie to another table) name "txtID" On before update i have following code.

Me![ID] = Forms![form1]![fieldID] OR me.txtid = Forms![form1]![fieldID]
Forms![form1].visible = true

Good Luck
Dianna Goldsberg
 

Users who are viewing this thread

Back
Top Bottom