Hi!
I made a access database for recording PC repairing information for my neighbours. I use a form named Customer to store my neighbours' information while use its subform named Problem_Solving to store maintenance records. What I want to do is to show the subform, Old_PC_Configuration_x and New_PC_Configuration_x, which are also the subform of subform Problem_Solving when I open the Problem_Solving. There is a field called computers to control how many subform, Old_PC_Configuration_x and New_PC_Configuration_x, which mean the configurations of neighbours' computers and are also the subform of Problem_Solving, should be displayed. The program is as follows:
Now the question is what form event handler should I choose everytime I open the Problem_Solving? form_open? form_load? form_activate? form_beforequery? form_gotfocus? Most of them only triger the event once while I expect everytime I open the Problem_Solving then the computers' configuration subform would be correctly displayed.
Any ideas would be very appreciated!
Maybe my access database is too complicated to be devised. I just use subform embeded in subform skill to devise this database since I have long time not contact access. What I want to do is when I click the subform Problem_Solving in the form Customer, subform Computer configuration would be displayed according to a field in Problem_Solving. For example, there are 3 PCs in one's family, then 3 old PC configurations and 3 new PC configurtions after maintenance would be displayed. Since the numbers of PCs in each family is different, so different PC configurations would be showed according to the field computers. The program trigger time is just when I open Problem_Solving. I just wonder which event handler would be used. I tried form_load, form_open, form_activate, form_beforerender,form_gotfocus, but the program only runs once after I click the Prolem_Solving. If I choose another Problem_Solving in another Customer, the program would not be trigered probably because the form had been opened already. This will lead to display too many or too little PCs regarding to his own PC numbers when I open another form Customer.
Thanks.
I made a access database for recording PC repairing information for my neighbours. I use a form named Customer to store my neighbours' information while use its subform named Problem_Solving to store maintenance records. What I want to do is to show the subform, Old_PC_Configuration_x and New_PC_Configuration_x, which are also the subform of subform Problem_Solving when I open the Problem_Solving. There is a field called computers to control how many subform, Old_PC_Configuration_x and New_PC_Configuration_x, which mean the configurations of neighbours' computers and are also the subform of Problem_Solving, should be displayed. The program is as follows:
Code:
Private Sub Form_Open(Cancel As Integer)
Dim i, j As Integer
Dim k As String
Dim objDB As Database
Dim objRS As Recordset
Me.ID.SetFocus
k = ID.Text
Set objDB = CurrentDb()
Set objRS = objDB.OpenRecordset("select * from Problem_Solving where ID=" & k, dbOpenDynaset)
MsgBox "select * from Problem_Solving where ID=" & k
'MsgBox objRS.Fields("Computers")
j = 1
If IsNull(objRS.Fields("Computers")) Then
i = 1
Else
i = CInt(objRS.Fields("Computers"))
End If
Do While j <= 5
If j <= i Then
Me.Controls("Old_PC_Config_" & j).Visible = True
Me.Controls("New_PC_Config_" & j).Visible = True
Else
Me.Controls("Old_PC_Config_" & j).Visible = False
Me.Controls("New_PC_Config_" & j).Visible = False
End If
j = j + 1
Loop
End Sub
Any ideas would be very appreciated!
Maybe my access database is too complicated to be devised. I just use subform embeded in subform skill to devise this database since I have long time not contact access. What I want to do is when I click the subform Problem_Solving in the form Customer, subform Computer configuration would be displayed according to a field in Problem_Solving. For example, there are 3 PCs in one's family, then 3 old PC configurations and 3 new PC configurtions after maintenance would be displayed. Since the numbers of PCs in each family is different, so different PC configurations would be showed according to the field computers. The program trigger time is just when I open Problem_Solving. I just wonder which event handler would be used. I tried form_load, form_open, form_activate, form_beforerender,form_gotfocus, but the program only runs once after I click the Prolem_Solving. If I choose another Problem_Solving in another Customer, the program would not be trigered probably because the form had been opened already. This will lead to display too many or too little PCs regarding to his own PC numbers when I open another form Customer.
Thanks.