Ste4en
12-23-2002, 07:49 AM
Just when I think I am finally starting to understand things I get tripped up by a simple problem -
I need the user to enter the Project Name and Number and then store that information. On each use of this mini-app the Project Name and Number will be the same. I want it to be a one time entry and it will be used in report headers.
I made a form with 2 fields - StoreJobNumber, StoreJobName. I added a button to "save" the data with the following code :
Public Sub SetNames_Click()
Dim JobName As String
Dim JobNumber As String
JobName = StoreJobTitle
JobNumber = StoreJobNumber
End Sub
Help Thanks
Ironis
12-23-2002, 08:03 AM
How do you store that information. do you want it to be stored in the memory or do you want it in a table..
Ste4en
12-23-2002, 08:21 AM
Thanks for responding - I have been storing the info in a table but had some problems keeping it to one record. Via the switchboard I want to be able to open the form showing the name and title values and allow an edit. I tried the table but when I opened a form based on the table I could not get it to show the only record - It was always a blank record and if you entered some info it added a new record.
Maybe I should be using the table but how can I limit it to one record and see just that record in form view.
Thanks
hi there
12-23-2002, 08:38 AM
if you want to display a single record in form view, design the form in "columnar" format. if you want to display a specific record upon opening the form you need to write code onto the "On Open" event for the form's properties. base that code on the criteria your using to find the specific record.
Ironis
12-23-2002, 08:49 AM
I have for example a form, which shows PeronID, name, date of birth etc.
If someone wants to add contact information, a form pops up, with on top the filled in name, date of birth etc. Under that is a subform on which the contact information can be added. The popup form, opens on a after_update event on a checkbox. So if someone checks the person to contactperson, the form with contactinformation will appear, and there will be no other records displayed, with contactinformation of other people.
Do you want something similar to this..
Ste4en
12-23-2002, 09:02 AM
I think "Hi There" has the right answer. When I open the form I want to see Record 1. I want to be able to change record 1 but not add any other records. I tried the following but the form still shows a blank record when i open it.
Thanks again.
'------------------------------------------------------------
' Form_Open
'
'------------------------------------------------------------
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Form_Open_Err
DoCmd.GoToRecord acForm, "Job Details", acGoTo, 1
Form_Open_Exit:
Exit Sub
Form_Open_Err:
MsgBox Error$
Resume Form_Open_Exit
End Sub
Jack Cowley
12-23-2002, 09:10 AM
Set the forms Allow Addtions to No and you won't see the blank record. You won't need any code in the On Open event as only the one record will be displayed.
hth,
Jack
Ste4en
12-23-2002, 09:17 AM
Believe it ot not that's where I started this morning but when I set "Allow Additions to No - when I open the form it is just a grey box and no fields ...
Jack Cowley
12-23-2002, 09:32 AM
You have to put some data into the table or this won't work. If this is to be a one record table filled in by the user then you will have to have code to look at the table when the form is opened and if the record count is zero then set the Allow Additions to True else leave the property set to False.
Private Sub Form_Open(Cancel As Integer)
If Me.RecordsetClone.RecordCount = 0 Then
Me.AllowEdits = True
Else
Me.AllowEdits = False
End If
End Sub
hth,
Jack
Ste4en
12-23-2002, 09:45 AM
I do have the one record in the table and still get a grey form with no fields.............................
So something is wrong - I started again and it works fine...no idea why but something somewhere must have been checked or corrupted.
Thanks all for your help.
Steve
Jack Cowley
12-23-2002, 11:00 AM
You are welcome and I'm glad you got the problem sorted out...
Jack