Hi,
I have a form called Customer based on the table tblCustomer and
another form called Job based on the table Job
when the user enter the details for the Customer i have a button at the bottm of the form called EnterJob where it directs to the Job Form
I have included some code in EnterJob button so when the user clicks, it gets the value for Customer Name and Max value of the Job number and enter into the appropriate field in the Job form.. Code is :
Private Sub EnterJobLabel_Click()
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenForm "New_Job"
DoCmd.GoToRecord , , acNewRec
Forms!New_Job!Company_Name.Value = Forms!New_Customer!Company_Name.Value
Forms!New_Job!Job_No = DMax("Job_No", "CHS_Job") + 1
End Sub
I dont have problem to get the company name from the current form and palce it to the job form..
but i cant get the Max number for Job_No .
what i am getting is an empty field.
I think Dmax function works fine but it is not assigning the value into the Job_No field in Job Form
could anyone tell me what i have done wrong???
regards,
Catherine
2 3399
Hi,
I have a form called Customer based on the table tblCustomer and
another form called Job based on the table Job
when the user enter the details for the Customer i have a button at the bottm of the form called EnterJob where it directs to the Job Form
I have included some code in EnterJob button so when the user clicks, it gets the value for Customer Name and Max value of the Job number and enter into the appropriate field in the Job form.. Code is :
Private Sub EnterJobLabel_Click()
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenForm "New_Job"
DoCmd.GoToRecord , , acNewRec
Forms!New_Job!Company_Name.Value = Forms!New_Customer!Company_Name.Value
Forms!New_Job!Job_No = DMax("Job_No", "CHS_Job") + 1
End Sub
I dont have problem to get the company name from the current form and palce it to the job form..
but i cant get the Max number for Job_No .
what i am getting is an empty field.
I think Dmax function works fine but it is not assigning the value into the Job_No field in Job Form
could anyone tell me what i have done wrong???
regards,
Catherine
Sorry guys.
I got that working...
i declared the field as Text .silly me...
only now i noticed it.
I changed it to number and its all working.. i would hav gone with autonumber but i want to get the max number through VBA
regards,
Catherine
Sorry guys.
I got that working...
i declared the field as Text .silly me...
only now i noticed it.
I changed it to number and its all working.. i would hav gone with autonumber but i want to get the max number through VBA
regards,
Catherine
Just an observation Catherine... if your db is used by you only then fine, but if you intend to use it in a multi user environment you might want to revisit the design on the way you are passing that value over?.
It is possible in a MU environment using that method, that 'someone else' will grab the number you have passed over statically to the job form and use it to insert a job before you had the chance to do so. Potentially when you come to applying the Dmax number you requested as a new record you'll get a 'Duplicates not allowed' message.
You might want to look at the BeforeInsert event of the Job form to grab the latest number for your job and base the Customer to whom it applies as the value of the 'Openargs' of the form?
where openargs 'value' is passed over to jobs form as part of the DoCmd.Openform arguments command...... from the customers form. -
Private Sub Form_BeforeInsert(Cancel As Integer)
-
'I'll leave you to do your own error handling here
-
dim mynewnum as long
-
mynewnum= DMax("[JobID]","YourJobTable","[CustomerID]='" & Me.OpenArgs &")
-
Me!JobID=mynewnum
-
Me!CustomerID=Me.Openargs
-
-
End sub
-
Regards
Jim
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Scott |
last post by:
I have a database with an input form. The field "DailyID" on the form
is to increment automatically with each new entry, then reset itself
back to "1" at midnight and/or the change of date.
...
|
by: lukeargent |
last post by:
Hi All,
I have come across some rather weird error that I can only assume is
something to do with my ADP file connecting to SQL Server 2000.
I'm using Access XP as my front end.
In simple...
|
by: Ron |
last post by:
Hi All,
Okay, here's the deal: Access2000/WinXP. Have a database that's split,
FE/BE with multiple users having FE and one of those users also has BE
(still split though...). Have a form on...
|
by: Ed Marzan |
last post by:
Greetings,
I have a query that returns varying prices for the same item in the
following manner.
Item1 Price1
Item1 Price2
Item1 Price3
Item1 Price4
|
by: jacc14 |
last post by:
Hi
This is the second query I have had with Dmax. The first one I resolved as it was in a form and by using DMAX everytime I click for new record it gave a new order number ie dmax("ordernumber",...
|
by: joeyrhyulz |
last post by:
Hi,
I'm trying to make a very simple update statement (in Oracle) in jet
sql that seems much more difficult than it should be.
The root of my problem is that I'm trying to update a field on a...
|
by: barmatt80 |
last post by:
Ran into a problem, just as I thought I had it working.
Dim strCurrentFiscalYear As String
strCurrentFiscalYear = DLookup("", "YearReset", " = 1")
Dim strLastFiscalYear As String
...
|
by: nrtyme |
last post by:
Hello,
I need to add several new records to Table2 from Table1. Table2
contains a field called that needs to be the previous
maximum value of incremented by 1.
Below is my code but i keep...
|
by: DanicaDear |
last post by:
I have a report named "rptHOTSTICKS_EXPIRING" based on a query named "HOSTICKS_SHIPPING_REPORT Query". The query contains these fields:
ORDER_NUM (text)
CUST_NUM (text)
Name, address, contact...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |