By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,062 Members | 1,358 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,062 IT Pros & Developers. It's quick & easy.

form does not display when it is opened

P: 14
Hey guys, I'm a newbie to the forum and to access and require some major help. I accepted a new position with my co. with the chance to broaden my horizon but it has been more an up hill battle than I expected. With that said here is my dilemma: I inherited a DB that pretty complex with forms and loads of tables and queries, most of which I somewhat understand. I have a form that allows me and any other user to update the DB, however it does not display when it is opened. the same form when copied to another DB opens with out any problem.
can anyone assist me in the matter?
P.s if additional info is needed i.e., code etc please don't hesitate to ask.
Any help will be greatly appreciated.
Jun 5 '07 #1
Share this Question
Share on Google+
22 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
Hey guys, I'm a newbie to the forum and to access and require some major help. I accepted a new position with my co. with the chance to broaden my horizon but it has been more an up hill battle than I expected. With that said here is my dilemma: I inherited a DB that pretty complex with forms and loads of tables and queries, most of which I somewhat understand. I have a form that allows me and any other user to update the DB, however it does not display when it is opened. the same form when copied to another DB opens with out any problem.
can anyone assist me in the matter?
P.s if additional info is needed i.e., code etc please don't hesitate to ask.
Any help will be greatly appreciated.
If the form works ok in another database it is probably not a corruption issue. That's the good news (LOL)

OK

How is this form being opened in the database? Is it through a switchboard, another form or by just clicking on the form in the list?

If it is through another form I will need to see the code behind the command button used to open the form.

I will also need to see any code behind the on load and on open events of the form being opened.

This could take a while to figure out.
Jun 6 '07 #2

P: 14
It's being opened from another form by clicking on the form.

Here's the code:
Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Form_Load()
  3. 'Clean_House
  4. Dim rs As Recordset
  5.  
  6.     Form_frmMain.Caption = Replace(CurrentProject.Name, "HRDB.mdb", "") & " - " & Form_frmMain.Caption
  7.     Set rs = New Recordset
  8.     prevForm = Me.Name
  9.  
  10.     If CurrALevel = "Administrator" Or CurrALevel = "Developer" Then
  11.         If reLogin = True Then
  12.             cmdAdmin.Visible = True
  13.             cmdLogin.Visible = True
  14.             cmd570.Visible = True
  15.             Me.lblUser.Caption = "User: " & CurrName & " -- Level: " & CurrALevel
  16.         End If
  17.         cmdGSMUpdt.Visible = True
  18.     Else
  19.         cmdAdmin.Visible = False
  20.         cmdLogin.Visible = False
  21.         cmdGSMUpdt.Visible = False
  22.         Me.lblUser.Caption = ""
  23.     End If
  24.  
  25.     If CurrRDRUpdt = True Then
  26.         cmdUpdateRDR.Visible = True
  27.     Else
  28.         cmdUpdateRDR.Visible = False
  29.     End If
  30.  
  31.     If CurrSTView = True Then
  32.         cmdStaffing.Visible = True
  33.     Else
  34.         cmdStaffing.Visible = False
  35.     End If
  36.  
  37.     Load_Config_Info
  38.     cboReport.RowSource = ""
  39.     rs.Open "select * from ReportList order by displayname", CurrentProject.Connection
  40.     rs.MoveFirst
  41.  
  42.     Do Until rs.EOF
  43.         If IsNull(rs!securitycriteria) = True Then
  44.             Me.cboReport.AddItem rs!DisplayName
  45.         ElseIf rs!securitycriteria = "GSM" And CurrGSMView = True Then
  46.             Me.cboReport.AddItem rs!DisplayName
  47.         ElseIf rs!securitycriteria = "LBM" And CurrLBMView = True Then
  48.             Me.cboReport.AddItem rs!DisplayName
  49.         ElseIf rs!securitycriteria = "RDRConf" And CurrRDRConf = True Then
  50.             Me.cboReport.AddItem rs!DisplayName
  51.         ElseIf rs!securitycriteria = "PEND" And CurrPendVu = True Then
  52.             Me.cboReport.AddItem rs!DisplayName
  53.         Else
  54.             'Nothing
  55.         End If
  56.         rs.MoveNext
  57.     Loop
  58.  
  59.     rs.Close
  60.     Set rs = Nothing
  61.  
  62.     cboReport.Value = "Please Choose A Report from this dropdown list"
  63.     reLogin = False
  64. End Sub
  65. -------------------------------------------
  66.  
  67. Private Sub Load_Config_Info()
  68. Dim rs As Recordset
  69.     Set rs = New Recordset
  70.  
  71.     rs.Open "select LASTUPDATE as maxdat from CONFIG", CurrentProject.Connection
  72.     LastRDRUpdate = FormatDateTime(rs.Fields("maxdat").Value, vbShortDate)
  73.  
  74.     rs.Close
  75.     rs.Open "select prevrdrupdt from config", CurrentProject.Connection
  76.     PrevRDRUpdate = Format(rs.Fields("prevrdrupdt").Value, "mm/dd/yyyy")
  77.     rs.Close
  78.  
  79.     If PrevRDRUpdate = #12:00:00 AM# Then PrevRDRUpdate = #11/9/2006#
  80.     ThisSDate = LastRDRUpdate
  81.     ThisEDate = LastRDRUpdate
  82.  
  83.     Set rs = Nothing
  84. End Sub
  85.  
  86.  
Jun 7 '07 #3

missinglinq
Expert 2.5K+
P: 3,532
I'm a little confused about a couple of things.

What do you mean by "doesn't display?" Nothing happens, or none of your controls show up?

What's the Record Source of the form?

Obviously the Record Source is present in the second form. Is it present and does it actually have data in it in the first database?
Jun 7 '07 #4

P: 14
The actual form which allows me to view/add/delete info does not show up. A blank image is display.

The record source is a table in access, all data are present

I'm a little confused about a couple of things.

What do you mean by "doesn't display?" Nothing happens, or none of your controls show up?

What's the Record Source of the form?

Obviously the Record Source is present in the second form. Is it present and does it actually have data in it in the first database?
Jun 8 '07 #5

P: 14
Here's the code for the form:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4.  
  5. Private Sub cmdAdd_Click()
  6. cmdSave.Visible = True
  7. cmdCXL.Visible = True
  8. cmdNewBase.Visible = False
  9. cmdOpenUpdt.Visible = False
  10. Form_frmRELO570.AllowAdditions = True
  11. Form_frmRELO570.DataEntry = True
  12. Form_RELO570.Visible = False
  13.  
  14. End Sub
  15.  
  16. Private Sub cmdCXL_Click()
  17. Form.Undo
  18. cmdSave.Visible = False
  19. cmdNewBase.Visible = True
  20. cmdOpenUpdt.Visible = True
  21. Form_frmRELO570.DataEntry = False
  22. Form_frmRELO570.AllowAdditions = False
  23. Form_RELO570.Visible = True
  24. cmdCXL.Visible = False
  25. End Sub
  26.  
  27. Private Sub cmdDel_Click()
  28. Dim CURWKR As String
  29. CURWKR = fullname
  30. If MsgBox("ARE YOU SURE YOU WANT TO DELETE " & Chr(13) & "WORKER ID: " & WKR_ID & " - " & fullname, vbYesNo) = vbYes Then
  31.  
  32. Form_RELO570.RecordSource = ""
  33. DoCmd.RunSQL "DELETE FROM RELO570 WHERE FULLNAME = '" & CURWKR & "'"
  34. Form_RELO570.RecordSource = "RELO570"
  35. End If
  36. End Sub
  37.  
  38. Private Sub cmdEXIT_Click()
  39. DoCmd.Close
  40. End Sub
  41.  
  42. Private Sub cmdNewBase_Click()
  43. RecordSource = ""
  44. Form_RELO570.RecordSource = ""
  45. DoCmd.RunSQL "SELECT * INTO RELO570ORIGIN" & Format(Now(), "YYYYMMDDHHMMSS") & " FROM RELO570ORIGIN"
  46. DoCmd.RunSQL "SELECT * INTO RELO570ORIGIN FROM 570EXIT"
  47. DoCmd.RunSQL "DELETE FROM RELO570 WHERE INSTR(COMMENTS,'Remove from move sheet.')<>0"
  48. MsgBox "A new baseline for the excel spreadsheet has been created", vbOKOnly
  49. Form_RELO570.RecordSource = "RELO570"
  50. End Sub
  51.  
  52. Private Sub cmdOpenUpdt_Click()
  53. Shell "excel.exe " & MyDefDir & "\570Relocation\GNS570to222M&TReport.xlt", vbMaximizedFocus
  54. End Sub
  55.  
  56. Private Sub cmdSave_Click()
  57. cmdCXL.Visible = False
  58. cmdNewBase.Visible = True
  59. cmdOpenUpdt.Visible = True
  60. Form_frmRELO570.DataEntry = False
  61. Form_frmRELO570.AllowAdditions = False
  62. Form_RELO570.Visible = True
  63. cmdSave.Visible = False
  64. End Sub
  65.  
  66. Private Sub Form_Load()
  67. Form_frmMain.Visible = False
  68. End Sub
  69.  
  70. Private Sub Form_Unload(Cancel As Integer)
  71. Form_frmMain.Visible = True
  72. End Sub
  73.  
Jun 8 '07 #6

MMcCarthy
Expert Mod 10K+
P: 14,534
The actual form which allows me to view/add/delete info does not show up. A blank image is display.

The record source is a table in access, all data are present
Are you saying you get a blank empty form? This happens when there is not record to display.
Jun 8 '07 #7

P: 14
Not a blank form but rather an image. In other words there's an outline of the form. It work fine a few day ago
Jun 8 '07 #8

MMcCarthy
Expert Mod 10K+
P: 14,534
Not a blank form but rather an image. In other words there's an outline of the form. It work fine a few day ago
When I say blank I mean no controls. Just a grey shape (or whatever background it had)

Open the form in design view and have a look at the Record source property of the form. If this is a table try opening the table directly. If it's a query try running the query.
Jun 8 '07 #9

P: 14
Then you are correct in your assumption
Jun 8 '07 #10

MMcCarthy
Expert Mod 10K+
P: 14,534
Then you are correct in your assumption
Did you try opening the table or query behind the form as I suggested?
Jun 8 '07 #11

P: 14
The table opens up fine
Jun 8 '07 #12

MMcCarthy
Expert Mod 10K+
P: 14,534
The table opens up fine
OK if you try to open the form directly and not from the other form what happens?
Jun 8 '07 #13

P: 14
I encounter the same result
Jun 8 '07 #14

MMcCarthy
Expert Mod 10K+
P: 14,534
I encounter the same result
OK open the form in design view and go to properties.
  1. As previously mentioned check that the Record Source under the Data tab is correct.
  2. Check that Filter Property is not set
  3. There are two forms referred to in your code frmRELO570 and frmMain. Are either of these the current form? If not what is the current forms name
Once you check these we can move forward.
Jun 8 '07 #15

P: 14
Frm RELO570 is the form in questioned
Jun 8 '07 #16

MMcCarthy
Expert Mod 10K+
P: 14,534
Frm RELO570 is the form in questioned
OK leave it with me. I have to go out for a couple of hours. I'll look at it when I get back unless someone beats me to it.
Jun 8 '07 #17

P: 14
This will be appreciated greatly
Jun 8 '07 #18

missinglinq
Expert 2.5K+
P: 3,532
And just as an aside while we try to figure this out. It'll make life much easier for you as while as for us, anytime we try to help you, if you change how you refer to the current form in VBA code.

If the current form is named frmRELO570 and you are working in the VBE, which is to say the code window, behind that form, instead of writing, for instance

frmRELO570.AllowAdditions = True

simply write

Me.AllowAdditions = True

The Me is shorthand, if you will, for the current form's name. This can be used anytime you're referring to the form's properties! Referring to any other form from frmRELO570 you would, of course, still use the long method for that other form.
Jun 8 '07 #19

FishVal
Expert 2.5K+
P: 2,653
Here's the code for the form:
Option Compare Database
Option Explicit


Private Sub cmdAdd_Click()
cmdSave.Visible = True
cmdCXL.Visible = True
cmdNewBase.Visible = False
cmdOpenUpdt.Visible = False
Form_frmRELO570.AllowAdditions = True
Form_frmRELO570.DataEntry = True
Form_RELO570.Visible = False

End Sub

Private Sub cmdCXL_Click()
Form.Undo
cmdSave.Visible = False
cmdNewBase.Visible = True
cmdOpenUpdt.Visible = True
Form_frmRELO570.DataEntry = False
Form_frmRELO570.AllowAdditions = False
Form_RELO570.Visible = True
cmdCXL.Visible = False
End Sub

Private Sub cmdDel_Click()
Dim CURWKR As String
CURWKR = fullname
If MsgBox("ARE YOU SURE YOU WANT TO DELETE " & Chr(13) & "WORKER ID: " & WKR_ID & " - " & fullname, vbYesNo) = vbYes Then

Form_RELO570.RecordSource = ""
DoCmd.RunSQL "DELETE FROM RELO570 WHERE FULLNAME = '" & CURWKR & "'"
Form_RELO570.RecordSource = "RELO570"
End If
End Sub

Private Sub cmdEXIT_Click()
DoCmd.Close
End Sub

Private Sub cmdNewBase_Click()
RecordSource = ""
Form_RELO570.RecordSource = ""
DoCmd.RunSQL "SELECT * INTO RELO570ORIGIN" & Format(Now(), "YYYYMMDDHHMMSS") & " FROM RELO570ORIGIN"
DoCmd.RunSQL "SELECT * INTO RELO570ORIGIN FROM 570EXIT"
DoCmd.RunSQL "DELETE FROM RELO570 WHERE INSTR(COMMENTS,'Remove from move sheet.')<>0"
MsgBox "A new baseline for the excel spreadsheet has been created", vbOKOnly
Form_RELO570.RecordSource = "RELO570"
End Sub

Private Sub cmdOpenUpdt_Click()
Shell "excel.exe " & MyDefDir & "\570Relocation\GNS570to222M&TReport.xlt", vbMaximizedFocus
End Sub

Private Sub cmdSave_Click()
cmdCXL.Visible = False
cmdNewBase.Visible = True
cmdOpenUpdt.Visible = True
Form_frmRELO570.DataEntry = False
Form_frmRELO570.AllowAdditions = False
Form_RELO570.Visible = True
cmdSave.Visible = False
End Sub

Private Sub Form_Load()
Form_frmMain.Visible = False
End Sub

Private Sub Form_Unload(Cancel As Integer)
Form_frmMain.Visible = True
End Sub

Could you clarify how many forms actually are involved in discussion.
1) You have frmMain which visibility depends on whether the form with code above loaded or unloaded.
2) You have a form the code of which you have provided. Plz, provide its name and the way it is being opened (from frmMain to my mind).
3) The code above deals with frmRELO570 and RELO570 forms in a really bizzare way. What it actually supposed to do?

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub cmdAdd_Click()
  3.     cmdSave.Visible = True
  4.     cmdCXL.Visible = True
  5.     cmdNewBase.Visible = False
  6.     cmdOpenUpdt.Visible = False
  7.     Form_frmRELO570.AllowAdditions = True
  8.     Form_frmRELO570.DataEntry = True
  9.     Form_RELO570.Visible = False
  10.  
  11. End Sub
  12.  
4) In msg#3 you've provided Form_Load event handler code. To what form does it relate?

Will be glad to help you when you will clarify me forms relationships.
Jun 9 '07 #20

MMcCarthy
Expert Mod 10K+
P: 14,534
I have edited the code slightly including commenting out some lines that made the form visible and invisible. After adding this code, open the form in design view and make sure the visible property is set to yes.

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit 
  3.  
  4. Private Sub cmdAdd_Click()
  5.     cmdSave.Visible = True
  6.     cmdCXL.Visible = True
  7.     cmdNewBase.Visible = False
  8.     cmdOpenUpdt.Visible = False
  9.     Me.AllowAdditions = True
  10.     Me.DataEntry = True
  11.     'Me.Visible = False
  12. End Sub
  13. Private Sub cmdCXL_Click()
  14.     Me.Undo
  15.     cmdSave.Visible = False
  16.     cmdNewBase.Visible = True
  17.     cmdOpenUpdt.Visible = True
  18.     Me.DataEntry = False
  19.     Me.AllowAdditions = False
  20.     'Me.Visible = True
  21.     cmdCXL.Visible = False
  22. End Sub
  23. Private Sub cmdDel_Click()
  24. Dim CURWKR As String
  25.     CURWKR = FullName
  26.     If MsgBox("ARE YOU SURE YOU WANT TO DELETE " & Chr(13) & "WORKER ID: " & WKR_ID & " - " & FullName, vbYesNo) = vbYes Then
  27.         Me.RecordSource = ""
  28.         DoCmd.RunSQL "DELETE FROM RELO570 WHERE FULLNAME = '" & CURWKR & "'"
  29.         Me.RecordSource = "RELO570"
  30.     End If
  31. End Sub
  32. Private Sub cmdEXIT_Click()
  33.     DoCmd.Close
  34. End Sub
  35. Private Sub cmdNewBase_Click()
  36.     Me.RecordSource = ""
  37.     DoCmd.RunSQL "SELECT * INTO RELO570ORIGIN" & Format(Now(), "YYYYMMDDHHMMSS") & " FROM RELO570ORIGIN"
  38.     DoCmd.RunSQL "SELECT * INTO RELO570ORIGIN FROM 570EXIT"
  39.     DoCmd.RunSQL "DELETE FROM RELO570 WHERE INSTR(COMMENTS,'Remove from move sheet.')<>0"
  40.     MsgBox "A new baseline for the excel spreadsheet has been created", vbOKOnly
  41.     Me.RecordSource = "RELO570"
  42. End Sub
  43. Private Sub cmdOpenUpdt_Click()
  44.     Shell "excel.exe " & MyDefDir & "\570Relocation\GNS570to222M&TReport.xlt", vbMaximizedFocus
  45. End Sub
  46. Private Sub cmdSave_Click()
  47.     cmdCXL.Visible = False
  48.     cmdNewBase.Visible = True
  49.     cmdOpenUpdt.Visible = True
  50.     Me.DataEntry = False
  51.     Me.AllowAdditions = False
  52.     'Me.Visible = True
  53.     cmdSave.Visible = False
  54. End Sub
  55. Private Sub Form_Load()
  56.     Forms!frmMain.Visible = False
  57. End Sub
  58. Private Sub Form_Unload(Cancel As Integer)
  59.     Forms!frmMain.Visible = True
  60. End Sub
  61.  
  62.  
Jun 11 '07 #21

P: 14
Thx greatly, this is some good stuff. how can someone like me with no prior knowledge of VB learn relatively quickly?
Jun 12 '07 #22

MMcCarthy
Expert Mod 10K+
P: 14,534
Thx greatly, this is some good stuff. how can someone like me with no prior knowledge of VB learn relatively quickly?
Unfortunately, it's not really a quickly learned language. You can pick up some basics fairly easily by using the command button wizard and examining the code created and convert existing macros to VBA and examine how VBA handles the macro functions.

There is also a number of tutorials on various topics in the Articles section of this site. There is an indexed list of them here. Opening the help file from the VBA editor window will also give you an extensive help section.

Mary
Jun 12 '07 #23

Post your reply

Sign in to post your reply or Sign up for a free account.