If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
|
Thread Tools | Display Modes |
#11
|
|||
|
|||
The main form name.
-- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, I don't mean to sound stupid but do I replace MyForm with the main form name or the subform name of the other form? Do I put them in quotes? Thanks "Douglas J Steele" wrote: If the form is already open, you can set a filter for it: With Forms("MyForm") .Filter = "LEAKID = " & Me.LEAKID .FilterOn = True End With Note that this code will raise an error if the form is not open. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, I used the DoCmd.OpenForm, like you had suggested, and that worked fine but I had a problem. Since the form is already opened, the DoCmd.OpenForm is opening another instance of the form there lies the problem. The main form within the subform is already opened. The pop up dialog asking for user name and date, is opened when the user clicks the Edit button. Thats how the dialog form is opened. I was thinking maybe a DoCmd.GoTo Record would work, but I don't know how to write the code for that. Can you possibly help me with that? Thanks "Douglas J. Steele" wrote: How are you opening the form? Assuming you're using DoCmd.OpenForm, you can pass it a Where clause: DoCmd.OpenForm "MyForm",,, "LEAKID = " & Me.LEAKID -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, Maybe I am going about this the wrong way. I will tell you what I want to do, and maybe you can point me in the right direction? I have a form frmADD_LEAK_FORM, which has a subform frmADD_LEAK_SUBFORM. In the subform, I have a command button EDIT, which allows the users to update/edit exisiting data. I want when the user clicks the EDIT button, a pop-up dialog form pops up, asking the user to enter their name and current date. When they click the okay button on the pop up form, I want them taken to the record they want to update in the subform. The code I had before was not doing this, the user kept getting taken to the first record of the subform. Below is the code I had before. I am new to VB. I have been trying a lot of different things. Any help will very much be appreciated. Private Sub cmdOK_Click() On Error GoTo Err_cmdOK_Click DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70 Forms!frmADD_LEAK_FORM.AllowEdits = True DoCmd.Close acForm, Me.Name Exit_cmdOK_Click: Exit Sub Err_cmdOK_Click: MsgBox Err.Description Resume Exit_cmdOK_Click End Sub Thanks in advance. "Douglas J Steele" wrote: If LEAKID is both a field in the underlying recordset AND a textbox on your form, you could be running into problems with Access not knowing to which LEAKID you're trying to refer. What I always do is rename my textbox controls, so that I'd have txtLEAKID bound to the LEAKID field in the recordset. However, if LEAKID is your Autonumber field, why are you trying to set it to Null? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, LEAKID is an autonumber field. It in a table. Everytime a leak is entered, a LEAKID is created, its the primary key. Thanks "Douglas J Steele" wrote: What data type is the LEAKID field? If it's text, you need to enclose the value being passed in quotes: RecordsetClone.FindFirst "LEAKID=" & Chr$(34) & LEAKID & Chr$(34) Also, what is LEAKID: in other words, where are you getting that value from? If it's the name of a control on your form, you might want to use Me.LEAKID. If it's a variable that's defined elsewhere, how is it declared? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Hello, Does anyone know why I'm getting a type mismatch error in the following code? rivate Sub cmdOK_Click() On Error GoTo Err_cmdOK_Click Dim FrmName As Form_frmLEAK_FILE_FORM With Forms(FrmName) RecordsetClone.FindFirst "LEAKID=" & LEAKID Bookmark = RecordsetClone.Bookmark LEAKID = Null '.setfocus End With Exit_cmdOK_Click: Exit Sub Err_cmdOK_Click: MsgBox Err.Description Resume Exit_cmdOK_Click End Sub I want to find a record with [LEAKID] in the subform in the frmADD_LEAK_FORM from the frmEDIT_FORM. Thanks |
#12
|
|||
|
|||
Douglas,
Its not working. I get a parameter asking for the primary key "LEAKID". I really don't know what to do now...please help me. "Douglas J. Steele" wrote: The main form name. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, I don't mean to sound stupid but do I replace MyForm with the main form name or the subform name of the other form? Do I put them in quotes? Thanks "Douglas J Steele" wrote: If the form is already open, you can set a filter for it: With Forms("MyForm") .Filter = "LEAKID = " & Me.LEAKID .FilterOn = True End With Note that this code will raise an error if the form is not open. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, I used the DoCmd.OpenForm, like you had suggested, and that worked fine but I had a problem. Since the form is already opened, the DoCmd.OpenForm is opening another instance of the form there lies the problem. The main form within the subform is already opened. The pop up dialog asking for user name and date, is opened when the user clicks the Edit button. Thats how the dialog form is opened. I was thinking maybe a DoCmd.GoTo Record would work, but I don't know how to write the code for that. Can you possibly help me with that? Thanks "Douglas J. Steele" wrote: How are you opening the form? Assuming you're using DoCmd.OpenForm, you can pass it a Where clause: DoCmd.OpenForm "MyForm",,, "LEAKID = " & Me.LEAKID -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, Maybe I am going about this the wrong way. I will tell you what I want to do, and maybe you can point me in the right direction? I have a form frmADD_LEAK_FORM, which has a subform frmADD_LEAK_SUBFORM. In the subform, I have a command button EDIT, which allows the users to update/edit exisiting data. I want when the user clicks the EDIT button, a pop-up dialog form pops up, asking the user to enter their name and current date. When they click the okay button on the pop up form, I want them taken to the record they want to update in the subform. The code I had before was not doing this, the user kept getting taken to the first record of the subform. Below is the code I had before. I am new to VB. I have been trying a lot of different things. Any help will very much be appreciated. Private Sub cmdOK_Click() On Error GoTo Err_cmdOK_Click DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70 Forms!frmADD_LEAK_FORM.AllowEdits = True DoCmd.Close acForm, Me.Name Exit_cmdOK_Click: Exit Sub Err_cmdOK_Click: MsgBox Err.Description Resume Exit_cmdOK_Click End Sub Thanks in advance. "Douglas J Steele" wrote: If LEAKID is both a field in the underlying recordset AND a textbox on your form, you could be running into problems with Access not knowing to which LEAKID you're trying to refer. What I always do is rename my textbox controls, so that I'd have txtLEAKID bound to the LEAKID field in the recordset. However, if LEAKID is your Autonumber field, why are you trying to set it to Null? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, LEAKID is an autonumber field. It in a table. Everytime a leak is entered, a LEAKID is created, its the primary key. Thanks "Douglas J Steele" wrote: What data type is the LEAKID field? If it's text, you need to enclose the value being passed in quotes: RecordsetClone.FindFirst "LEAKID=" & Chr$(34) & LEAKID & Chr$(34) Also, what is LEAKID: in other words, where are you getting that value from? If it's the name of a control on your form, you might want to use Me.LEAKID. If it's a variable that's defined elsewhere, how is it declared? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Hello, Does anyone know why I'm getting a type mismatch error in the following code? rivate Sub cmdOK_Click() On Error GoTo Err_cmdOK_Click Dim FrmName As Form_frmLEAK_FILE_FORM With Forms(FrmName) RecordsetClone.FindFirst "LEAKID=" & LEAKID Bookmark = RecordsetClone.Bookmark LEAKID = Null '.setfocus End With Exit_cmdOK_Click: Exit Sub Err_cmdOK_Click: MsgBox Err.Description Resume Exit_cmdOK_Click End Sub I want to find a record with [LEAKID] in the subform in the frmADD_LEAK_FORM from the frmEDIT_FORM. Thanks |
#13
|
|||
|
|||
Did you rename the text box on the form as I recommended?
And does LEAKID exist in the recordset that is bound to your form? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, Its not working. I get a parameter asking for the primary key "LEAKID". I really don't know what to do now...please help me. "Douglas J. Steele" wrote: The main form name. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, I don't mean to sound stupid but do I replace MyForm with the main form name or the subform name of the other form? Do I put them in quotes? Thanks "Douglas J Steele" wrote: If the form is already open, you can set a filter for it: With Forms("MyForm") .Filter = "LEAKID = " & Me.LEAKID .FilterOn = True End With Note that this code will raise an error if the form is not open. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, I used the DoCmd.OpenForm, like you had suggested, and that worked fine but I had a problem. Since the form is already opened, the DoCmd.OpenForm is opening another instance of the form there lies the problem. The main form within the subform is already opened. The pop up dialog asking for user name and date, is opened when the user clicks the Edit button. Thats how the dialog form is opened. I was thinking maybe a DoCmd.GoTo Record would work, but I don't know how to write the code for that. Can you possibly help me with that? Thanks "Douglas J. Steele" wrote: How are you opening the form? Assuming you're using DoCmd.OpenForm, you can pass it a Where clause: DoCmd.OpenForm "MyForm",,, "LEAKID = " & Me.LEAKID -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, Maybe I am going about this the wrong way. I will tell you what I want to do, and maybe you can point me in the right direction? I have a form frmADD_LEAK_FORM, which has a subform frmADD_LEAK_SUBFORM. In the subform, I have a command button EDIT, which allows the users to update/edit exisiting data. I want when the user clicks the EDIT button, a pop-up dialog form pops up, asking the user to enter their name and current date. When they click the okay button on the pop up form, I want them taken to the record they want to update in the subform. The code I had before was not doing this, the user kept getting taken to the first record of the subform. Below is the code I had before. I am new to VB. I have been trying a lot of different things. Any help will very much be appreciated. Private Sub cmdOK_Click() On Error GoTo Err_cmdOK_Click DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70 Forms!frmADD_LEAK_FORM.AllowEdits = True DoCmd.Close acForm, Me.Name Exit_cmdOK_Click: Exit Sub Err_cmdOK_Click: MsgBox Err.Description Resume Exit_cmdOK_Click End Sub Thanks in advance. "Douglas J Steele" wrote: If LEAKID is both a field in the underlying recordset AND a textbox on your form, you could be running into problems with Access not knowing to which LEAKID you're trying to refer. What I always do is rename my textbox controls, so that I'd have txtLEAKID bound to the LEAKID field in the recordset. However, if LEAKID is your Autonumber field, why are you trying to set it to Null? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, LEAKID is an autonumber field. It in a table. Everytime a leak is entered, a LEAKID is created, its the primary key. Thanks "Douglas J Steele" wrote: What data type is the LEAKID field? If it's text, you need to enclose the value being passed in quotes: RecordsetClone.FindFirst "LEAKID=" & Chr$(34) & LEAKID & Chr$(34) Also, what is LEAKID: in other words, where are you getting that value from? If it's the name of a control on your form, you might want to use Me.LEAKID. If it's a variable that's defined elsewhere, how is it declared? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Hello, Does anyone know why I'm getting a type mismatch error in the following code? rivate Sub cmdOK_Click() On Error GoTo Err_cmdOK_Click Dim FrmName As Form_frmLEAK_FILE_FORM With Forms(FrmName) RecordsetClone.FindFirst "LEAKID=" & LEAKID Bookmark = RecordsetClone.Bookmark LEAKID = Null '.setfocus End With Exit_cmdOK_Click: Exit Sub Err_cmdOK_Click: MsgBox Err.Description Resume Exit_cmdOK_Click End Sub I want to find a record with [LEAKID] in the subform in the frmADD_LEAK_FORM from the frmEDIT_FORM. Thanks |
#14
|
|||
|
|||
Douglas,
If you are asking if I changed the name, yes I did. It is as follows: Name - LEAK Control Source - LEAKID Did I need to change the control source? There is a LEAKID in the subform of the original form and a LEAKID in the Edit form. "Douglas J Steele" wrote: Did you rename the text box on the form as I recommended? And does LEAKID exist in the recordset that is bound to your form? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, Its not working. I get a parameter asking for the primary key "LEAKID". I really don't know what to do now...please help me. "Douglas J. Steele" wrote: The main form name. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, I don't mean to sound stupid but do I replace MyForm with the main form name or the subform name of the other form? Do I put them in quotes? Thanks "Douglas J Steele" wrote: If the form is already open, you can set a filter for it: With Forms("MyForm") .Filter = "LEAKID = " & Me.LEAKID .FilterOn = True End With Note that this code will raise an error if the form is not open. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, I used the DoCmd.OpenForm, like you had suggested, and that worked fine but I had a problem. Since the form is already opened, the DoCmd.OpenForm is opening another instance of the form there lies the problem. The main form within the subform is already opened. The pop up dialog asking for user name and date, is opened when the user clicks the Edit button. Thats how the dialog form is opened. I was thinking maybe a DoCmd.GoTo Record would work, but I don't know how to write the code for that. Can you possibly help me with that? Thanks "Douglas J. Steele" wrote: How are you opening the form? Assuming you're using DoCmd.OpenForm, you can pass it a Where clause: DoCmd.OpenForm "MyForm",,, "LEAKID = " & Me.LEAKID -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, Maybe I am going about this the wrong way. I will tell you what I want to do, and maybe you can point me in the right direction? I have a form frmADD_LEAK_FORM, which has a subform frmADD_LEAK_SUBFORM. In the subform, I have a command button EDIT, which allows the users to update/edit exisiting data. I want when the user clicks the EDIT button, a pop-up dialog form pops up, asking the user to enter their name and current date. When they click the okay button on the pop up form, I want them taken to the record they want to update in the subform. The code I had before was not doing this, the user kept getting taken to the first record of the subform. Below is the code I had before. I am new to VB. I have been trying a lot of different things. Any help will very much be appreciated. Private Sub cmdOK_Click() On Error GoTo Err_cmdOK_Click DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70 Forms!frmADD_LEAK_FORM.AllowEdits = True DoCmd.Close acForm, Me.Name Exit_cmdOK_Click: Exit Sub Err_cmdOK_Click: MsgBox Err.Description Resume Exit_cmdOK_Click End Sub Thanks in advance. "Douglas J Steele" wrote: If LEAKID is both a field in the underlying recordset AND a textbox on your form, you could be running into problems with Access not knowing to which LEAKID you're trying to refer. What I always do is rename my textbox controls, so that I'd have txtLEAKID bound to the LEAKID field in the recordset. However, if LEAKID is your Autonumber field, why are you trying to set it to Null? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, LEAKID is an autonumber field. It in a table. Everytime a leak is entered, a LEAKID is created, its the primary key. Thanks "Douglas J Steele" wrote: What data type is the LEAKID field? If it's text, you need to enclose the value being passed in quotes: RecordsetClone.FindFirst "LEAKID=" & Chr$(34) & LEAKID & Chr$(34) Also, what is LEAKID: in other words, where are you getting that value from? If it's the name of a control on your form, you might want to use Me.LEAKID. If it's a variable that's defined elsewhere, how is it declared? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Hello, Does anyone know why I'm getting a type mismatch error in the following code? rivate Sub cmdOK_Click() On Error GoTo Err_cmdOK_Click Dim FrmName As Form_frmLEAK_FILE_FORM With Forms(FrmName) RecordsetClone.FindFirst "LEAKID=" & LEAKID Bookmark = RecordsetClone.Bookmark LEAKID = Null '.setfocus End With Exit_cmdOK_Click: Exit Sub Err_cmdOK_Click: MsgBox Err.Description Resume Exit_cmdOK_Click End Sub I want to find a record with [LEAKID] in the subform in the frmADD_LEAK_FORM from the frmEDIT_FORM. Thanks |
#15
|
|||
|
|||
I changed them both now. Both the Name and the Control Source are named
"LEAK". My code is as follows: Private Sub cmdOK_Click() On Error GoTo Err_cmdOK_Click DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70 With Forms("frmADD_LEAK_FORM") .Filter = "LEAKID=" & Me.LEAK .FilterOn = True End With DoCmd.Close acForm, Me.Name Exit_cmdOK_Click: Exit Sub Err_cmdOK_Click: MsgBox Err.Description Resume Exit_cmdOK_Click End Sub I'm still getting the parameter asking for the LEAKID. I don't know if this helps, but, the LEAKID is not in the main form, its in the subform. I really appreciate your help. "Douglas J Steele" wrote: Did you rename the text box on the form as I recommended? And does LEAKID exist in the recordset that is bound to your form? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, Its not working. I get a parameter asking for the primary key "LEAKID". I really don't know what to do now...please help me. "Douglas J. Steele" wrote: The main form name. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, I don't mean to sound stupid but do I replace MyForm with the main form name or the subform name of the other form? Do I put them in quotes? Thanks "Douglas J Steele" wrote: If the form is already open, you can set a filter for it: With Forms("MyForm") .Filter = "LEAKID = " & Me.LEAKID .FilterOn = True End With Note that this code will raise an error if the form is not open. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, I used the DoCmd.OpenForm, like you had suggested, and that worked fine but I had a problem. Since the form is already opened, the DoCmd.OpenForm is opening another instance of the form there lies the problem. The main form within the subform is already opened. The pop up dialog asking for user name and date, is opened when the user clicks the Edit button. Thats how the dialog form is opened. I was thinking maybe a DoCmd.GoTo Record would work, but I don't know how to write the code for that. Can you possibly help me with that? Thanks "Douglas J. Steele" wrote: How are you opening the form? Assuming you're using DoCmd.OpenForm, you can pass it a Where clause: DoCmd.OpenForm "MyForm",,, "LEAKID = " & Me.LEAKID -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, Maybe I am going about this the wrong way. I will tell you what I want to do, and maybe you can point me in the right direction? I have a form frmADD_LEAK_FORM, which has a subform frmADD_LEAK_SUBFORM. In the subform, I have a command button EDIT, which allows the users to update/edit exisiting data. I want when the user clicks the EDIT button, a pop-up dialog form pops up, asking the user to enter their name and current date. When they click the okay button on the pop up form, I want them taken to the record they want to update in the subform. The code I had before was not doing this, the user kept getting taken to the first record of the subform. Below is the code I had before. I am new to VB. I have been trying a lot of different things. Any help will very much be appreciated. Private Sub cmdOK_Click() On Error GoTo Err_cmdOK_Click DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70 Forms!frmADD_LEAK_FORM.AllowEdits = True DoCmd.Close acForm, Me.Name Exit_cmdOK_Click: Exit Sub Err_cmdOK_Click: MsgBox Err.Description Resume Exit_cmdOK_Click End Sub Thanks in advance. "Douglas J Steele" wrote: If LEAKID is both a field in the underlying recordset AND a textbox on your form, you could be running into problems with Access not knowing to which LEAKID you're trying to refer. What I always do is rename my textbox controls, so that I'd have txtLEAKID bound to the LEAKID field in the recordset. However, if LEAKID is your Autonumber field, why are you trying to set it to Null? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, LEAKID is an autonumber field. It in a table. Everytime a leak is entered, a LEAKID is created, its the primary key. Thanks "Douglas J Steele" wrote: What data type is the LEAKID field? If it's text, you need to enclose the value being passed in quotes: RecordsetClone.FindFirst "LEAKID=" & Chr$(34) & LEAKID & Chr$(34) Also, what is LEAKID: in other words, where are you getting that value from? If it's the name of a control on your form, you might want to use Me.LEAKID. If it's a variable that's defined elsewhere, how is it declared? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Hello, Does anyone know why I'm getting a type mismatch error in the following code? rivate Sub cmdOK_Click() On Error GoTo Err_cmdOK_Click Dim FrmName As Form_frmLEAK_FILE_FORM With Forms(FrmName) RecordsetClone.FindFirst "LEAKID=" & LEAKID Bookmark = RecordsetClone.Bookmark LEAKID = Null '.setfocus End With Exit_cmdOK_Click: Exit Sub Err_cmdOK_Click: MsgBox Err.Description Resume Exit_cmdOK_Click End Sub I want to find a record with [LEAKID] in the subform in the frmADD_LEAK_FORM from the frmEDIT_FORM. Thanks |
#16
|
|||
|
|||
What's the connection between the main form and the subform?
I was assuming that LEAKID was a key field on the main form. Before going any further, if the name of the field in the recordset it LEAKID, the field needs to be bound to that field. All I was trying to do is not have the control and field have the same name: that can lead to confusion. I think you're going to have to step back and explain in a bit of detail. What tables are involved? What's being shown on your form, what's been shown on your subform and what's the link between the form and subform? This thread is getting pretty long: it might be better to start a new one. That also has the advantage that others who have been ignoring this thread (thinking it's been resolved) may contribute. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... I changed them both now. Both the Name and the Control Source are named "LEAK". My code is as follows: Private Sub cmdOK_Click() On Error GoTo Err_cmdOK_Click DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70 With Forms("frmADD_LEAK_FORM") .Filter = "LEAKID=" & Me.LEAK .FilterOn = True End With DoCmd.Close acForm, Me.Name Exit_cmdOK_Click: Exit Sub Err_cmdOK_Click: MsgBox Err.Description Resume Exit_cmdOK_Click End Sub I'm still getting the parameter asking for the LEAKID. I don't know if this helps, but, the LEAKID is not in the main form, its in the subform. I really appreciate your help. "Douglas J Steele" wrote: Did you rename the text box on the form as I recommended? And does LEAKID exist in the recordset that is bound to your form? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, Its not working. I get a parameter asking for the primary key "LEAKID". I really don't know what to do now...please help me. "Douglas J. Steele" wrote: The main form name. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, I don't mean to sound stupid but do I replace MyForm with the main form name or the subform name of the other form? Do I put them in quotes? Thanks "Douglas J Steele" wrote: If the form is already open, you can set a filter for it: With Forms("MyForm") .Filter = "LEAKID = " & Me.LEAKID .FilterOn = True End With Note that this code will raise an error if the form is not open. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, I used the DoCmd.OpenForm, like you had suggested, and that worked fine but I had a problem. Since the form is already opened, the DoCmd.OpenForm is opening another instance of the form there lies the problem. The main form within the subform is already opened. The pop up dialog asking for user name and date, is opened when the user clicks the Edit button. Thats how the dialog form is opened. I was thinking maybe a DoCmd.GoTo Record would work, but I don't know how to write the code for that. Can you possibly help me with that? Thanks "Douglas J. Steele" wrote: How are you opening the form? Assuming you're using DoCmd.OpenForm, you can pass it a Where clause: DoCmd.OpenForm "MyForm",,, "LEAKID = " & Me.LEAKID -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, Maybe I am going about this the wrong way. I will tell you what I want to do, and maybe you can point me in the right direction? I have a form frmADD_LEAK_FORM, which has a subform frmADD_LEAK_SUBFORM. In the subform, I have a command button EDIT, which allows the users to update/edit exisiting data. I want when the user clicks the EDIT button, a pop-up dialog form pops up, asking the user to enter their name and current date. When they click the okay button on the pop up form, I want them taken to the record they want to update in the subform. The code I had before was not doing this, the user kept getting taken to the first record of the subform. Below is the code I had before. I am new to VB. I have been trying a lot of different things. Any help will very much be appreciated. Private Sub cmdOK_Click() On Error GoTo Err_cmdOK_Click DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70 Forms!frmADD_LEAK_FORM.AllowEdits = True DoCmd.Close acForm, Me.Name Exit_cmdOK_Click: Exit Sub Err_cmdOK_Click: MsgBox Err.Description Resume Exit_cmdOK_Click End Sub Thanks in advance. "Douglas J Steele" wrote: If LEAKID is both a field in the underlying recordset AND a textbox on your form, you could be running into problems with Access not knowing to which LEAKID you're trying to refer. What I always do is rename my textbox controls, so that I'd have txtLEAKID bound to the LEAKID field in the recordset. However, if LEAKID is your Autonumber field, why are you trying to set it to Null? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Douglas, LEAKID is an autonumber field. It in a table. Everytime a leak is entered, a LEAKID is created, its the primary key. Thanks "Douglas J Steele" wrote: What data type is the LEAKID field? If it's text, you need to enclose the value being passed in quotes: RecordsetClone.FindFirst "LEAKID=" & Chr$(34) & LEAKID & Chr$(34) Also, what is LEAKID: in other words, where are you getting that value from? If it's the name of a control on your form, you might want to use Me.LEAKID. If it's a variable that's defined elsewhere, how is it declared? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Trini Gal" wrote in message ... Hello, Does anyone know why I'm getting a type mismatch error in the following code? rivate Sub cmdOK_Click() On Error GoTo Err_cmdOK_Click Dim FrmName As Form_frmLEAK_FILE_FORM With Forms(FrmName) RecordsetClone.FindFirst "LEAKID=" & LEAKID Bookmark = RecordsetClone.Bookmark LEAKID = Null '.setfocus End With Exit_cmdOK_Click: Exit Sub Err_cmdOK_Click: MsgBox Err.Description Resume Exit_cmdOK_Click End Sub I want to find a record with [LEAKID] in the subform in the frmADD_LEAK_FORM from the frmEDIT_FORM. Thanks |
|
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
type mismatch error importing from excel | mary anne | General Discussion | 1 | August 17th, 2005 04:25 AM |
How to fix: Data type mismatch criteria expression | Martin | Running & Setting Up Queries | 4 | August 4th, 2005 06:08 PM |
Data type mismatch in criteria expression error returned... | Rashar Sharro via AccessMonster.com | Running & Setting Up Queries | 3 | April 28th, 2005 08:49 PM |
ByRef Type Mismatch inconsistent | Bruce | General Discussion | 4 | March 29th, 2005 08:43 PM |