![]() |
|
|
#1
|
|||
|
|||
|
hello all,
i have 2 form in my db. 1st - use to add new data. means the blank form 2nd - use to update or edit the data. ive successfully create the 1st form with the blank form onActive. but im failed to create the 2nd form. even theres a data in a table, still the data does not appear in a 2nd form. why? |
|
#2
|
||||
|
||||
|
How many different places did you post this?
Make sure the Data Entry property of the form is No. Personally, I would use one form and open it in one mode or the other. |
|
#3
|
|||
|
|||
|
hehehe. i posted this on 3 different forum. ok i have tried ur suggestion but didnt work
|
|
#4
|
|||
|
|||
|
if i use only 1 form, then i need to have 2 command button right? for updating and editing. then i know bout the coding for the updating which is for the blank form. but i dont know the coding for the editing.
|
|
#5
|
||||
|
||||
|
The datamode argument of OpenForm would dictate how the form is opened. If the form was bound to the table, using the appropriate argument would open it blank for data entry or displaying existing records.
|
|
#6
|
|||
|
|||
|
cant understand..=(..can u xplain it?
|
|
#7
|
||||
|
||||
|
Start by looking in VBA help on OpenForm, specifically at the DataMode argument.
|
|
#8
|
||||
|
||||
|
Let me get you straight you have two forms one which is meant for data entry always opens blank and the other you intend to use should open with data in it. Now my question are you trying to open the second form from another form based on some criteria? anyways you can try out the following.
Open the second form in design view and go to Form properties and check Whether Data Entry is set to No, if it is Yes make it no. Now if you are opening you form from another fForm using say a CommandButton then you will have a code similar to one below in the OnClick event of the CommandButton Dim stDocName As String Dim stLinkCriteria As String stDocName = "Main21" stLinkCriteria = "[FraudRef]=" & Me![FraudRef] DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd Check the portion marked in Red if it is acFormAdd then change it to acFormEdit. This should solve your problem. if it does please mark this thread solved. |
|
#9
|
|||
|
|||
|
it have 2 command button for each form to open it. 1 for the updating and another is for editing. the editing form shud be open with a data in it.
|
|
#11
|
|||
|
|||
|
ive followed what did u said then get the error, for the "[FraudRef]=
|
|
#12
|
||||
|
||||
|
Well this is an example and you nee to add the names of the fields in your form.
The example here opens a form called Main21 and displays a record whose FraudRef is = to the FraudRef of a record on a Form called Main Form. Now here is what you need to do Dim stDocName As String Dim stLinkCriteria As String stDocName = "Name of the Form you want to open" stLinkCriteria = "[Name of the Field in the form you want to open]=" & Me![Name of the Field from which you want to open another form] DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit you got this error because you don't have the field name FraudRef do you ha!ha! feel free to ask if you have any more problems. |
|
#13
|
|||
|
|||
|
hahahha..shame on me.. i got a lot of problem with this lor...
..between, thank you very muchhh
|
|
#14
|
|||
|
|||
|
and i also receive this message whenever i tried to add new data to my db by using the form
|
|
#15
|
||||
|
||||
|
Let me guess you are very new to access right.
Never mind don't be dissapointed we are all learning: Case 1: When you want to open a form using a command Button to enter data that means it will be blank!!! Name of the Form Main The following will be the code: Private Sub Command8_Click() On Error GoTo Err_Command8_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "Main" 'Name of the form you want to open DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd 'acFormAdd ensures that the form is opened blank Exit_Command8_Click: Exit Sub Err_Command8_Click: MsgBox Err.Description Resume Exit_Command8_Click End Sub Case 2: When you want to open a form using a command Button to see all the data in the form Private Sub Command8_Click() On Error GoTo Err_Command8_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "Main" 'Name of the form you want to open DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit 'acFormEdit ensures that the form is opened with all the records Exit_Command8_Click: Exit Sub Err_Command8_Click: MsgBox Err.Description Resume Exit_Command8_Click End Sub Case 3: This is Opening a Form from another Form base on some Criteria. I will use the Code that I had posted for your easy understanding: I have two Forms: Main and Main 21 I have a Field FraudRef on Both Main and Main21 Now I want to Open Form Main21 From Form Main to Display a Record Where the FraudRef in both the Forms are same. e.g. FraudRef in Main = FraudRef in Main21 Private Sub Command13_Click() On Error GoTo Err_Command13_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "Main21" 'Name of the Form I want to open stLinkCriteria = "[FraudRef]=" & Me![FraudRef] 'I have set the criteria where Main21 for will open and display a record DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd 'Whose FraudRef = FraudRef on Form Main Exit_Command13_Click: Exit Sub Err_Command13_Click: MsgBox Err.Description Resume Exit_Command13_Click End Sub Three cases are there decide which one you require. |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Problem updating from within a query.
|
Frank Nye | Queries | 5 | 10-14-2009 08:33 AM |
| new problem: Updating Combo box | ali-gagi | Forms | 4 | 07-06-2009 05:29 PM |
| combo not updating form | cjamps | Forms | 5 | 04-14-2009 10:00 AM |
| Updating Table field from Form | Kunuk | Access | 0 | 02-26-2009 08:41 PM |
| Updating SQL server form Access form? | slash75 | Forms | 1 | 09-06-2008 12:39 PM |