First Published 13 Jan 2023 Difficulty level : Easy
The use of artificial intelligence (AI) has been widely discussed in the media recently, particularly since the release in Nov 2022 of a new tool called ChatGPT by the tech company OpenAI
Currently ChatGPT is free in order to both promote its use and to improve its reliability by widespread testing.
It has been extremely successful, with the result that the company's servers aren't always able to cope with the high demand
ChatGPT has been designed to answer questions in a conversational manner and can often give answers that sound like a person has written them.
This has resulted in many educational institutions banning its use for student assignments.
In addition, several online forums such as Stackoverflow and UtterAccess are trying hard to prevent its use for answering members' questions
Inevitably this will be difficult to enforce as it never gives the exact same answer twice.
So how accurate/valid are its answers?
I asked Chat GPT several questions as a test
1. Can I use Access to create a desktop database?
In my opinion, this is a good response giving an accurate representation of the product for this purpose
2. Can I use Access to create a web database?
Although the answer contained some correct information, it failed to mention the important point that Access web databases were deprecated in 2018
Next I asked ChatGPT to write some simple code
3. Get the computer name using Access VBA
The first function supplied using Environ is the simplest method of getting this information and works fine as written. The code indentation is a nice touch
Function GetComputerName() As String
GetComputerName = Environ("COMPUTERNAME")
End Function
The second function using WMI also works correctly but the two object variables are not properly defined
Function GetComputerName() As String
Dim objWMIService, objComputer
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set objComputer = objWMIService.ExecQuery("Select * from Win32_ComputerSystem").ItemIndex(0)
GetComputerName = objComputer.Name
End Function
Next I asked something slightly trickier
4. Calculate age using Access VBA
Function CalculateAge(dob As Date) As Integer
CalculateAge = DateDiff("yyyy", dob, Date())
End Function
Although the code may look OK at first glance, it will give inaccurate results where the birthday hasn't yet occurred this year
Examples:
NOTE:
See my article Age Calculation for code that does always work correctly for this purpose
Next I asked ChatGPT to do the opposite:
5. Calculate date of birth using age in Access VBA
This was a deliberately poor question. What its actually doing is calculating the date of birth for someone born on the current date
Function CalculateDOB(age As Integer) As Date
CalculateDOB = DateAdd("yyyy", -age, Date())
End Function
Examples:
A better question would have been to calculate the year of birth
However when I did so, ChatGPT offered the following
OOPS! In this case, not all the function code was placed in the code block
The idea behind the code is valid though unnecessarily verbose. It is also subject to the same issues as to when the birthday occurs as the earlier example.
Also, the current year has somehow been hard coded as 2020 into the response.
However, ChatGPT isn't yet 'intelligent' enough to realise that someone currently aged 25 in 2023 wouldn't have been born in 1995.
Clearly, artificial intelligence (AI) isn't going away and its usage will become increasinly widespread in coming years
However, at this stage, ChatGPT is nowhere near the stage that it should be used to replace actual programmers . . . even for simple tasks
Whilst it may provide a useful start in writing simple code, it needs someone who understands the code to check it for accuracy and amend as appropriate.
Feedback
Please use the contact form below to let me know whether you found this article useful or if you have any questions.
Please also consider making a donation towards the costs of maintaining this website. Thank you
Colin Riddington Mendip Data Systems Last Updated 13 Jan 2023
Return to Access Articles
Page 1 of 2
1
2
Return To Top