Hello i wonder if it is possible to auto populate a number field on a from?
Yes it is a number field in the table.
My intention with this function is to make the system more user friendly and easier to use.
We have two forms, and two tables, frmA, frmB, tableA and tableB.
Table A represents the customers and table B represents orders.
Form A is a detailed view of the customer, with all the contact information and summarized product orders. (Just the most essential for an overview.)
Form B adds new orders or views a more detailed view on the order, with related products, company name, exetra.
The ideé is simple, pass the custID from formA to fromB and insert the CustID to the field which will tie the table records together.
The thought was simple, take the ID from formA and pass it to fromB and feed the field on the form which ties tabelB with tableA.
This is the code i use to pass the ID from formA:
Code:
Dim varID As Variant varID = Me!CustID
DoCmd.OpenForm "frmName", acNormal, "", "", acFormEdit, acDialog, OpenArgs:=varID
FromB receives the IDnumber from fromA.
Now when we got the CustID on fromB all we have to do is update the txtCustID field with the value, so this record with be tied to the related record on tableA.
On formB we have:
- OrderID(pk)(hidden for users)
- txtCustID(fk)(hidden for users)
- -other fields-
In order to set stsCustID to the same as CustID i have trid the following code.
Code:
Debug.Print "CustID: ", Me.txtCustID
Debug.Print "CustID.value: ", Me.txtCustID.Value
OpenArgs = Me.txtCustIDOpenArgs = Me.txtCustID.Value
OpenArgs = Me!txtCustID
OpenArgs = Me!txtCustID.Value
The debug.print returns a 0, both of them. (I did expect a null value as null because the field is literary empty, well so i thought.)
The others returned: "This property is write protected and can not be specified."
So i changed the field to a combobox. My ideé here was so have all the customers in the combobox and filter out the openargs value where the openargs value equals the CustID in the CustID table. Then the combobox would "autoupdate" itself in a way. But i recived this error "This property is write protected and can not be specified." again and now i'm out of options.
Any advice and pushes in the right direction is very welcome.
//ThornofSouls.