Hi
I have a form that works perfectly based on the following code in the ON LOAD property:
I needed to create a similar form for another table in that database, so I took this code and changed the table references:
When I open the 2nd form, all the fields show "#NAME?" as the value.
I have done this code-copying to create other forms sucessfully, but I can't get this one to work for the life of me.
Any ideas? I'm probably missing something VERY obvious.
Thanks!!
Jim DeGeorge![[wavey] [wavey] [wavey]](/data/assets/smilies/wavey.gif)
I have a form that works perfectly based on the following code in the ON LOAD property:
Code:
Private Sub Form_Load()
Me.RecordSource = "SELECT tblGaps.* FROM tblGaps WHERE tblGaps.DateClosed Is Not Null " _
& "AND tblGaps.Conversion = [Forms]![frmSignOn]![ctlConversion] ORDER BY tblGaps.[Gap#];"
Me.msgContact.Visible = False
Me.msgOwner.Visible = False
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim sql As String
sql = "SELECT Count(tblGaps.GapID) AS vCount FROM tblGaps "
sql = sql & "WHERE tblGaps.Gap_Status = 2 And tblGaps.Conversion = '" & [Forms]![frmSignOn]![ctlConversion] & "';"
Set db = CurrentDb()
Set rs = db.OpenRecordset(sql, dbOpenDynaset)
If rs!vcount = 0 Then
DoCmd.Close acForm, Me.NAME, acSaveYes
[Forms]![frmGapMenu].Visible = True
Dim msg1, DgDef1, Response1 As Variant
Beep
msg1 = "There is nothing to edit for this option." _
& vbCrLf & "Click OK to return to the previous menu. Thank you!"
DgDef1 = MB_OK + MB_ICONINFORMATION + MB_DEFBUTTON2
Response1 = MsgBox(msg1, DgDef1, Title)
Else
Me!lblClock.Caption = Format(Now, "dddd, mmmm d, yyyy, hh:mm:ss AMPM")
Me.TimerInterval = 1000
End If
End Sub
I needed to create a similar form for another table in that database, so I took this code and changed the table references:
Code:
Private Sub Form_Load()
Me.RecordSource = "SELECT tblMilestones.* FROM tblMilestones WHERE tblMilestones.DateClosed Is Not Null " _
& "And tblMilestones.Conversion) = [Forms]![frmSignOn]![ctlConversion] ORDER BY tblMilestones.[Milestone#];"
Me.msgContact.Visible = False
Me.msgOwner.Visible = False
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim sql As String
sql = "SELECT Count(tblMilestones.MilestoneID) AS vCount FROM tblMilestones "
sql = sql & "WHERE tblMilestones.Milestone_Status = 2 AND tblMilestones.Conversion = [Forms]![frmSignOn]![ctlConversion];"
Set db = CurrentDb()
Set rs = db.OpenRecordset(sql, dbOpenDynaset)
MsgBox (rs!vcount)
If rs!vcount = 0 Then
DoCmd.Close acForm, Me.NAME, acSaveYes
[Forms]![frmMilestoneMenu].Visible = True
Dim msg1, DgDef1, Response1 As Variant
Beep
msg1 = "There is nothing to edit for this option." _
& vbCrLf & "Click OK to return to the previous menu. Thank you!"
DgDef1 = MB_OK + MB_ICONINFORMATION + MB_DEFBUTTON2
Response1 = MsgBox(msg1, DgDef1, Title)
Else
Me!lblClock.Caption = Format(Now, "dddd, mmmm d, yyyy, hh:mm:ss AMPM")
Me.TimerInterval = 1000
End If
End Sub
When I open the 2nd form, all the fields show "#NAME?" as the value.
I have done this code-copying to create other forms sucessfully, but I can't get this one to work for the life of me.
Any ideas? I'm probably missing something VERY obvious.
Thanks!!
Jim DeGeorge
![[wavey] [wavey] [wavey]](/data/assets/smilies/wavey.gif)